I am using ansible to script a deployment for an API. I would like this to work sequentially through each host in my inventory file so that I can fully deploy to one machine at a time.
With the out box behaviour, each task in my playbook is executed for each host in the inventory file before moving on to the next task.
How can I change this behaviour to execute all tasks for a host before starting on the next host? Ideally I would like to only have one playbook.
Thanks
Task executionBy default, Ansible executes each task in order, one at a time, against all machines matched by the host pattern. Each task executes a module with specific arguments.
you can run more playbooks using "ansible-playbook [OPTIONS] *. yml" command. This will execute all the playbooks NOT IN PARALLEL WAY, but in serial way, so first one playbook and after the execution, another playbook. This command can be helpful if you have many playbooks.
yaml . playbook. yaml. This playbook file instructs Ansible to execute the instructions on all hosts.
Ansible is not designed to run multiple playbooks at the same time in one process - for example, because the tasks differ from playbook to playbook and there is no step "taskA" in playbook1 and playbook2 at the same time. You need to run every playbook in one separate process (like with ansible-playbook ... & ).
Have a closer look at Rolling Updates:
What you are searching for is
- hosts: webservers serial: 1 tasks: - name: ...
Using the --forks=1 specify number of parallel processes to use (default=5)
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