Skip to content

Example 7

hosts.ini

[centos]
provisioner     ansible_connection=local
centos2         ansible_host=192.168.77.22      ansible_port=2345

[ubuntu]
ubuntu1         ansible_host=192.168.77.23

[linux:children]
centos
ubuntu

[linux:vars]
ansible_become=true

Tip

You can use the children notation to incorporate property inheritance in your invetories in order to desribe more complex systems.

Try to execute the whoami command on all hosts.

ansible all -m command -a "whoami"
What is the expected output of the command ?

The command will be run as the root user for all hosts since the centos and ubuntu groups are children of the linux group.