Seedtefan
Seedtefan

Reputation: 47

How to run 1 playbook for the same group by multiple plays aka threaded

Current setup that we do have ~2000 servers (in 1 group)

I would like to know if there is a way to run x.yml on all the group (where all the 2k servers are in ) but with multiple plays (threaded , or something)

ansible-playbook -i prod.ini -l my_group[50%] x.yml
ansible-playbook -i prod.ini -l my_group[other 50%] x.yml

solutions with awx or ansible-tower are not relevant.

using even 500-1000 forks didn't gave any improvement

Upvotes: 0

Views: 162

Answers (3)

Seedtefan
Seedtefan

Reputation: 47

resolved by using patterns my_group[:1000] and my_group[999:]

forks didnt give any time decrease in my case. also free strategy did multiplied the time which was pretty weird. also debugging free strategy summary is free difficult when u have 2k servers and about 50 tasks in playbook .

thanks everyone for sharing much appreciated

Upvotes: 0

Avish
Avish

Reputation: 49

As mentioned above, you should preferably increase fork and set the strategy to free. Increasing fork will help you run the playbook on more server and setting the strategy to free would allow you to run a task for servers independently without waiting for others.

Please refer to below doc for more clarifaction.

docs

Upvotes: 0

idriss Eliguene
idriss Eliguene

Reputation: 897

try to combine forks, and the free strategy.

the default behavior of Ansible is:

Ansible runs each task on all hosts affected by a play before starting the next task on any host, using 5 forks.

So event if your increase the forks number, the tasks on special forks will still wait any host finish to go ahead. The free strategy allows each host to run until the end of the play as fast as it can

- hosts: all
  strategy: free
  tasks:
  # ...

ansible-playbook -i prod.ini -f 500 -l my_group x.yml

Upvotes: 2

Related Questions