How to get host/group name for dynamic inventory?

Having ec2 dynamic inventory and pattern in hosts:

- hosts: [tag_Name_m*]

which variable holds the full host/tag/group name?

You can always see all the variables available to you by doing something like what was posted here: https://gryzli.info/2015/05/29/ansible-dump-all-variables/

The other option would be to just create a task that prints out current variables, example:

`

  • name: See Variables
    hosts: [tag_name_m*]
    connection: local
    tasks:
  • name: see vars

`

debug: var=vars

play_hosts has the ‘list of current hosts in play’