Hi,
We would like to use ansible as the services orchestration tool - so that it would stop and start services according to a dynamically changing configuration or playbooks. Something like puppet on steroids
The idea is for ansible to start a playbook immediately once configuration changes. Bonus for choosing correct playbook across several available (presumably by calculating the playbook affected by the changed variable). Same for changed playbook.
Is there something like this?
If you're on linux, you could use Incron[1] for this. Incron uses the
kernel's inotify system to trigger cron-style jobs, triggered on filesystem
events.
In your case, incron could be configured to run an ansible-playbook command
whenever your config files or playbooks change.
-erik
[1] http://inotify.aiken.cz/?section=incron&page=about&lang=en
So Ansible’s happier in push mode, however, there are already some options, and you don’t even need the cron approach above.
Look into “ansible-pull” which is suitable for wakeup on a crontab and will fetch down the latest of a playbook run.
(Also of interest – callbacks in Ansible Tower – which can be requested by cron via simple wget, and ask the server to push down it’s latest content. This can be a great way to manage a fleet of image based cloud deployments that just need a refresh, or otherwise ephmeral or autoscaling systems – but might not be for you)
In any case, assume you were using Ansible pull, use the --only-if-changed flag, and if the remote repo hasn’t changed, it won’t have any work to do.
Have it simply wakeup every 5 minutes and apply changes – no listening and no server would be required.
Now, one thought is ansible-pull probably use a check to see if it’s already running, to make that a bit easier – that’s one thing it currently doesn’t do.
But yeah, we love that we don’t have any daemons and don’t need a standing server infrastructure – it’s more secure, there are less moving parts, and we’d like to keep it that way
another option not discussed, ansible-playbook run from version control hooks. I was thinking of using this with --check on git push, but could work for your case.
A lot of folks do have it wired into Jenkins for similar functionality (this is very very very common), I also know of some that have it going through Gerritt (code review) before it fires too.