Hello All - 

I'm writing a local plugin where I'd like to be able to pass in the name of 
an Ansible host group and find out particular details about the relevant 
hosts - basically, I need to access groups and hostvars from a Python 
plugin. 

Is this possible?  I've done lots of Ansible but very limited plugin 
development for it, so apologies if this is a foolish question. Please 
point me in the right direction if there's some documentation I've missed!

Background:  

My actual aim is to create Amazon ELB loadbalancer target rules which point 
at the hosts in a particular group.  To do this, I need the EC2 instance 
IDs of those hosts.

I can get the instance info for all my hosts using ec2_instance_info, and I 
can match them up based on IP addresses with the information in `groups` 
and `hostvars`, but this kind of thing is very convoluted and unreadable in 
Jinja tags and filters. It would be easy and readable in Python.

I know how to do the EC2 side.  I just need to know how to do the inventory 
side, so I can get rid of things like:

groups[ groupname ] | map('extract', hostvars, ['ansible_default_ipv4', 
'address']) | list)

Suggestions of alternative approaches also welcome!

Many thanks!
Quentin

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/48587857-26fa-4a18-8466-c7cfa7076ebdo%40googlegroups.com.

Reply via email to