SaltStack is great in deployment automation, but I have to run a full blown integration test every time to check my sls files are just syntactically correct. E.g. if there are duplicated IDs or wrong indentation. Is there a way I can test my sls files in a matter of seconds and without complex environment setup? I am searching for some kind of linter for sls files.
There are at least two possibilities:
salt-call --local state.highstate test=True
will give you a feedback in a matter of seconds if your states (and other configuration files) are correct including the referenced modules.
An even lighter test is just rendering the SLS:
salt-call --local state.show_highstate
The --local parameter allows you to call salt without contacting the master. Additional parameters on the command line allow you to point the call to a specific directory with the files you want to test. Instead of calling highstate you can call a specific state to test/render only this state as described in the state module.
For more information:
http://docs.saltstack.com/en/latest/ref/states/testing.html
http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html
http://docs.saltstack.com/en/latest/ref/cli/salt-call.html
See https://github.com/saltstack/salt/issues/802 for an ongoing discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With