Question:
As far as i know, ansible has an option named --list-hosts
for listing hosts. Is there any option for listing host groups? Or any other way to come through?
Answer:
You can simply inspect the groups
variable using the debug
module:
1 2 |
ansible localhost -m debug -a 'var=groups.keys()' |
The above is using
groups.keys()
to get just the list of groups. You could drop the .keys()
part to see group membership as well:
1 2 |
ansible localhost -m debug -a 'var=groups' |