All,
We're trying to have automated tests in our Jenkins setup to run "smoke" and "lint" type of tests in our salt state files (.sls
). All google-foo so far has yielded very little information. There is a way to test via test=True
in the command line, but that doesn't work with a no-shell account (as Jenkin's accounts usually are).
I have not yet bumped into anyone doing this sort of automated testing of SaltStack states. So:
1) Is it possible
2) Anyone know of a good resource where I could look at
TIA.
Best Answer
Docker. Quick automated testing of server configuration is an undeniable real-world problem that docker nails. It can provide a clean computer already booted and listening on the network in a second. Start an image with /srv/salt bind-mounted and you can run
salt-call --local state.highstate -l debug
to test states without fussing withsalt-key
.I know SaltStack, Inc used LXC much the same way. They likely still do.
As for the test - if you are clever and careful with your states files you could consider a clean second run to be an indication of success.
This is difficult to achieve as some states will always re-run. Salt Stack has been good at fixing these states as they are found. In the meantime you will have to surround these states with inline jinja conditionals that execute commands on the minion at runtime:
There exists a jenkins-docker plugin:
Alternatively, you can automate the whole thing via the new docker-ng salt module: