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: Block of executed modules
      block:
        - name: Example 1
          debug:
            msg: This is Example 1
        - name: Example 2
          debug:
            msg: This is Example 2
        - name: Example 3
          debug:
            msg: This is Example 3

Tip

In order to group tasks that are somwhow linked together the user can apply the block directive.

Execute the following command

ansible-playbook playbook.yml