After further evaluation, I've found a way to achieve my desired result. 
However, look at the code makes me think that it's not exactly intended...

What I've done:


*destination_variable = private_ip_address*

*vpc_destination_variable = private_ip_address*
*destination_format = {0}@{1}*
*destination_format_tags = Name,private_ip_address*

This lets me set the ansible_hostname (or maybe it's inventory_hostname) to 
the label I want (instance_name@ip). However, ansible_ssh_host is then set 
to that same label, which isn't the correct SSH connection IP. So in my 
inventory, I reset ansible_ssh_host like so:

*[all:vars]*
*ansible_ssh_host={{ ec2_private_ip_address }}*

Willing to be this will break something at some point if for no reason but 
that when *destination_format* is used it doesn't run the name through the 
*to_safe* method in *ec2.py*.

On Wednesday, November 8, 2017 at 5:38:32 PM UTC-8, Ryan Fisher wrote:
>
> I'm creating a dynamic inventory using ec2.py (which is working great, 
> thanks!). One minor annoyance I'm running into is that the console output 
> that shows changes is labeled with the instances private IPs (as set by 
> *hostname_variable* or *[vpc_]destination_variable*). It would be nice to 
> label these instances based on tags or the ec2 vars (or combination). From 
> what I can tell, that isn't possible because:
>
>
>    1. *hostname_variable* only supports tags (not formatting or the ec2_* 
>    vars)
>    2. *destination_format* overrides *vpc_destination_variable*
>
> I can modify ec2.py to add the functionality I'm looking for to 
> *hostname_variable*, just wondering if there was a supported method for 
> doing this already.
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5f76a1ae-32eb-4e0c-8db0-73e9564e53d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to