Hostnames with EC2 inventory plugin

51 views
Skip to first unread message

os...@apartum.com

unread,
Apr 11, 2018, 3:19:51 AM4/11/18
to Ansible Project
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

flowerysong

unread,
Apr 11, 2018, 5:36:46 AM4/11/18
to Ansible Project
On Wednesday, April 11, 2018 at 3:19:51 AM UTC-4, os...@apartum.com wrote:
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

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.

os...@apartum.com

unread,
Apr 12, 2018, 3:45:42 AM4/12/18
to Ansible Project
Thank you very much for the information, and for the work! seems like ansible developers accepeted it, wich are great news.

Regards,
Oscar
Reply all
Reply to author
Forward
0 new messages