I have an ansible inventory file where I want some particular IPs to be a part of multiple instance groups. Is there any way with this can be achieved.
eg
[grp1]:[grp2]
IP1
IP2
usual way is this, however it's a pain when we need to edit IPs which will be common, and need to be removed/edited in 2 places.
[grp1]
IP1
IP2
[grp2]
IP1
IP2
Use host aliases and don't use IPs.
front ansible_host=<IP1>
back ansible_host=<IP2>
db ansible_host=<IP3>
[grp1]
web
db
[grp2]
back
db
So you can change ansible_host
for an alias and it is used everywhere in your inventory.