Salt state testing

Salt state testing

12 August 2015

Salt-call has a test option which is pretty cool.

salt-call state.highstate --id hostname test=True --out=yaml --out-file=c:\\salt\\out.txt

I must admit; I've learnt the hard way by creating a VM, running salt-call and investigating problems; then rolling back to a previous snapshot; which is a long winded process!

Testing like this speeds things up because I can at least check the order of execution of the states, requisite failures and spot problems within a couple minutes.

The out.txt file will look something like

local:
  pkg_|-kb2533523_|-kb_|-installed:
    __run_num__: 18
    changes: {}
    comment: "The following requisites were not found:\n                   require:\n\
      \                       sls: artifacts\n"
    result: false

In my case I could see there was an error with a requisite sls: artifact which I fixed.

To execute a specific state you can execute salt-call state.sls 'artifacts' test=True --out=yaml --out-file=c:\\salt\\out.txt

SaltStack