How to call groups in the inventory
#
To see all hosts in the inventory
ansible all -i inventory --list-hosts
ansible '*' -i inventory --list-hosts
To see all hosts by wild cards
ansible '*.example.com' -i inventory --list-hosts
ansible '192.168.1.*' -i inventory --list-hosts
To see hosts in groups ‘lab’ or ‘datacenter1’
ansible lab:datacenter1 -i inventory --list-hosts
To see hosts in groups ‘lab’ and ‘datacenter1’
ansible 'lab:&datacenter1' -i inventory --list-hosts
need single quote because of special character ‘&’
To see all hosts in group ‘datacenter’ except test2.example.com
ansible 'datacenter:!test2.example.com' -i inventory --list-hosts
Leave a comment