Skip to content

Example 1

hosts.yml

centos:
  hosts:
    provisioner:
      ansible_connection: local
    centos1:
      ansible_host: '192.168.77.22'
ubuntu:
  hosts:
    ubuntu1:
      ansible_host: '192.168.77.23'

playbook.yml

- hosts: all
  tasks:
    - name: 1st sleep
      command: sleep 5
    - name: 2nd sleep
      command: sleep 5
    - name: 3rd sleep
      command: sleep 5
    - name: 4th sleep
      command: sleep 5
    - name: 5th sleep
      command: sleep 5

Tip

Ansible's performance may depend on a variety of different factors. Always try to optimize your scripts for reduced time consumption.

Execute the following command

time ansible-playbook playbook.yml

Bonus round

Disale fact gathering and check how it impacts Ansible's performance.