I'm storing my salt sls files in a git repository, but I have the perennial problem that I can't verify my YAML represents a valid set of states that could be applied (I've also had difficulty validating my YAML -- that's much easier, though). Ideally, I'd like some way to verify my states on my workstation before committing them. Failing that, some way to check in a pre-receive hook so I can at least stop dodgy code from hitting the server.

  • 1
  • 1
    Thanks @ceejayoz, that's not a bad idea :). Whipped a one-liner in Python to do the same job, and a pre-commit hook won't be hard. I'll edit the question to emphasise the difficult bit... – Andrew Aylett Sep 5 '13 at 20:45
  • Could you post your solution as your answer? – davey Sep 6 '13 at 7:17
  • @davey, I only have an answer to the tangental question of validating YAML, not to the question of verifying Salt state files. Sorry for the confusion. – Andrew Aylett Sep 6 '13 at 7:32

You might want to try the test option with the salt command: http://docs.saltstack.com/en/latest/ref/states/testing.html

salt '*' state.highstate test=True

This also works with the salt-call command. It will parse all configuration files, will run all checks and will then list all commands that it would have been executed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.