Hostnames with EC2 inventory plugin

Hi,

I’m testing the new Amazon EC2 dynamic inventory plugin. I need to set the host names to the “Name” tag, but I don’t understand the documentation. Reading this: http://docs.ansible.com/ansible/latest/plugins/inventory/aws_ec2.html I understand I should write something like this:

`

    hostnames:
      - tag:Name=Name

`

But it doesn’t work. Also tried:

`

    hostnames:
      - tag-Key:Name

`

With no result. Also checked https://www.ansible.com/blog/dynamic-inventory-past-present-future, but gives no additional information about how to do it. Do you know the way to set inventory hostname to the Name tag? It’s the configuration I’m using to test:

`
plugin: aws_ec2
boto_profile: default
regions:

Regions to include in the inventory

  • us-east-1
    filters:

Criteria to include hosts in the inventory

tag:Environment: staging
instance-state-name: running
hostnames:

  • tag:Name
    #- private-dns-name
    strict_permissions: False

`

Regards,
Oscar

The inventory plugin does not currently have useful support for setting hostnames from tags. I submitted a pull request (https://github.com/ansible/ansible/pull/35880) to add this functionality, but it hasn’t been merged yet.

Thank you very much for the information, and for the work! seems like ansible developers accepeted it, wich are great news.

Regards,
Oscar