This is a topic I brushed up against yesterday and meant to blog about it at the end of the day but got a little busy. A lot of times when provisioning boxes locally in Vagrant I’ve thought it would be incredibly useful to be able to automatically test the system to ensure all the expected bits are provisioned as expected.
I’ll probably throw together a nice public demo but the short and skinny is to include a final Ansible provisioning step after the normal step that runs a test playbook of sorts against the system. For us we just dumped our test tags into our main roles and tag them as
test. Then in vagrant we exclude
test tagged tasks and then in the test phase we only run those tagged tasks. Below is an example for one of our services to test that two service processes are running and that the load balancer is also serving up responses that are the same as those running on the two processes.
I’ve also heard of other tools in this space like ServerSpec which may fit your bill if you’re not running Ansible or are running some mixed environment. So far I think Ansible fits well here but you’re definitely going to be a little limited due to the tests being in YAML. Although you could hypothetically write some custom modules or resort to shell wizardry if you need something more advanced.
I’m really excited about this… the idea we could have full test suites with each of our Ansible roles that can verify a whole swath of aspects like expected ulimits and the like is GREAT.