Ansible - Set the number of nodes a task will run against simultaneously using forks in ansible.cfg (Parallelism)
by
Jeremy Canfield |
Updated: August 25 2022
| Ansible articles
Forks determines how many managed nodes (e.g. the target systems) a task will be run against simultaneously. For a better understanding of forks, refer to Ansible - Understanding Forks.
By default, the forks directive in ansible.cfg is set to use 5 forks.
forks = 5
Command line option -f or --forks can be used to specify the number of fork, which will take precedence over the forks directive in ansible.cfg. In this example, forks is set to 10, so that each task in the playbook is executed against 10 managed nodes simultaneously.
ansible-playbook example.yml --forks 10
Did you find this article helpful?
If so, consider buying me a coffee over at