How to list all currently targeted hosts in an Ansible play


I am running an Ansible play and would like to list all the hosts targeted by it. Ansible docs mentions that this is possible, but their method doesn’t seem to work with a complex targeted group (targeting like hosts: web_servers:&data_center_primary)

I’m sure this is doable, but cant seem to find any further documentation on it. Is there a var with all the currently targeted hosts?


You are looking for ‘play_hosts’ variable

would result in


Leave a Reply