Ansible: Group and Group of Group's in Inventory
Inventory(Hosts) file contains the information of the Ansible nodes. We can group based on our use case like web servers, DB servers and uses these groups to execute commands on them. But you have to create a group in the inventory file, let see how to do that.
[webserver] IP_ADDRESS_1 IP_ADDRESS_2 IP_ADDRESS_3 [webserverduck] IP_ADDRESS_1 [dbserver] IP_ADDRESS_1 IP_ADDRESS_2 IP_ADDRESS_3 [clientduck:children] dbserver webserverduck
You can even assign variable nodes or group wise in inventory file
[webserverduck:vars] ansible_connection=ssh ansible_user=myotheruser gather_fact=no [dbserver] IP_ADDRESS_1 ansible_user=myuser IP_ADDRESS_2 IP_ADDRESS_3