Anyone on my team can SSH into our special deploy server, and from there run an Ansible playbook to push new code to machines.
We're worried about what will happen if two people try to do deploys simultaneously. We'd like to make it so that the playbook will fail if anyone else is currently running it.
Any suggestions for how to do this? The standard solution is to use a pid file, but Ansible does not have built-in support for these.
For such requirements where we need one tasks to run only once on a batch of hosts and we will be running that from Ansible controller node, we have feature parameter named run_once. When we have this parameter mentioned in a task, that task will run only once on first host it finds despite the host batch.
Ansible's parallel processes are known as forks, and the default number of forks is five. The more forks you set, the more resources are used on the Ansible control node.
You can also limit the hosts you target on a particular run with the --limit flag. Negated limit. Note that single quotes MUST be used to prevent bash interpolation.
Ansible works by spinning off forks of itself and talking to many remote systems independently. The forks parameter controls how many hosts are configured by Ansible in parallel. By default, the forks parameter in Ansible is a very conservative 5.
Personally I use RunDeck ( http://rundeck.org/ ) as a wrapper around my Ansible playbooks for multiple reasons:
There are many more good reasons of course, but my fingers are getting tired of typing ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With