Reputation: 217
I would like to pull values from AWS EC2 tags via Ansible. This works:
{{ hostvars[host]['ec2_private_ip_address'] }}
and will return the IP address. So, I'm getting EC2 data. However, I have a tag called app on my EC2 instances with values like Cassandra or PostGres, and I need to find out for each host I'm currently processing what app is associated with that post. Any ideas of how to grab the value of an EC2 tag?
Upvotes: 3
Views: 3792
Reputation: 1762
The accepted answer is no longer working for me, but led me to this which does work now.
{{ hostvars[inventory_hostname].tags.<tagKey>}}
Upvotes: 0
Reputation: 217
hostvars[inventory_hostname]['ec2_tag_xxx'] where xxx is the tag in question
Upvotes: 6