Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set forks for one task in ansible playbook

Tags:

ansible

I have one task in my playbook that I want to run on only one host at a time. The rest of the tasks I want to honor the --forks option. Is this possible?

like image 260
Todd Chapman Avatar asked Nov 12 '15 16:11

Todd Chapman


People also ask

How do I run a specific task in Ansible playbook?

The easiest way to run only one task in Ansible Playbook is using the tags statement parameter of the “ansible-playbook” command. The default behavior is to execute all the tags in your Playbook with --tags all .

How do you use a fork in Ansible?

Ansible uses batches for task execution, which are controlled by a parameter called forks . The default value for forks is 5, which means Ansible executes a task on the first five hosts, waits for the task to complete, and then takes the next batch of five hosts, and so on.

How do I control Ansible playbook only on specific hosts?

Using the --limit parameter of the ansible-playbook command is the easiest option to limit the execution of the code to only one host. The advantage is that you don't need to edit the Ansible Playbook code before executing to only one host.


1 Answers

Yes checkout rolling updates

specifically you can add a "serial: x" parameter for a play where x is the number of forks

like image 105
Petro026 Avatar answered Nov 02 '22 22:11

Petro026