By default Strategies in ansible is linear it means first task will complete on all client then only next task will start and so on....
[ansible@ip-172-31-80-19 ~]$ vi playbook100.yml
[ansible@ip-172-31-80-19 ~]$ cat playbook100.yml
-
name: "this is our first playbook."
hosts: all
strategy: linearw
tasks:
-
name: 'first task'
apt: name='apache2' state='present'
-
name: 'secound task'
command: touch /tmp/strategy_task2.txt
[ansible@ip-172-31-80-19 ~]$
[ansible@ip-172-31-80-19 ~]$ vi playbook100.yml
[ansible@ip-172-31-80-19 ~]$ cat playbook100.yml
-
name: "this is our first playbook."
hosts: all
strategy: linearw
tasks:
-
name: 'first task'
apt: name='apache2' state='present'
-
name: 'secound task'
command: touch /tmp/strategy_task2.txt
[ansible@ip-172-31-80-19 ~]$
-----------------------------------------------------------------------------
If you don't want to use linear Strategies then use free keyword
[ansible@ip-172-31-80-19 ~]$ vi playbook100.yml
[ansible@ip-172-31-80-19 ~]$ cat playbook100.yml
-
  name: "this is our first playbook."
  hosts: all
  strategy: free
  tasks:
    -
      name: 'first task'
      apt: name='apache2' state='present'
    -
      name: 'secound task'
      command: touch /tmp/strategy_task2.txt
[ansible@ip-172-31-80-19 ~]$
In this case all client are independent of each other it means if task is already install then it will run next task in place of waiting other client installation 
----------------------------------------------------------------------------------------------------------
By using serial we can tell at the time on how many client task will run .
Suppose we have 100 client by using this serial: 5  both the task will run on first 5 client then next 5 and so on.....
[ansible@ip-172-31-80-19 ~]$ vi playbook100.yml
[ansible@ip-172-31-80-19 ~]$ cat playbook100.yml
-
  name: "this is our first playbook."
  hosts: all
  serial: 5
  tasks:
    -
      name: 'first task'
      apt: name='apache2' state='present'
    -
      name: 'secound task'
      command: touch /tmp/strategy_task2.txt
[ansible@ip-172-31-80-19 ~]$
 
 
No comments:
Post a Comment