Salt State Testing via Jenkins
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 with salt-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:
{% if salt['cmd.retcode']('your test here') %}
some-identifier:
some.module:
- name: some anme
{% endif %}'
There exists a jenkins-docker plugin:
The aim of the docker plugin is to be able to use a docker host to dynamically provision a slave, run a single build, then tear-down that slave.
Alternatively, you can automate the whole thing via the new docker-ng salt module:
salt dockhost docker-ng.create states-qa rm=True binds="/srv/salt:/srv/salt"
salt dockhost docker-ng.retcode states-qa 'salt-call --local state.highstate' # run 1
salt dockhost docker-ng.retcode states-qa 'salt-call --local state.highstate' # run 2
salt dockhost docker-ng.stop states-qa