'How can I run an Ansible block one host at a time?
I have a playbook with something like this:
- name: Do this all one host at a time
block:
- name: Task A
# do task A
- name: Task B
# do task B
throttle: 1
I expect throttle: 1 to limit execution to one of the hosts at a time. It does this, but instead of running the whole block on host 1, then the whole block on host 2, etc. it runs Task A on host 1, Task A on host 2, Task B on host 1, Task B on host 2.
How can I run the entire block on each host in the group, one at a time?
(Note: there are other tasks in the playbook that should not run serially, hence not having the entire playbook run this way.)
Solution 1:[1]
You cannot do that on a block. What you are looking for is serial on a play. In a nutshell:
- name: Play those tasks serially
hosts: my_group
serial: 1
tasks:
- name: Task A
# do task A
- name: Task B
# do task B
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zeitounator |
