MrDuk MrDuk - 1 year ago 131
Ruby Question

Can I retrieve Ansible inventory without writing a file parser?

I'm working on a wrapper for our Ansible scripts in Ruby -- I'm trying to get the host list defined in our

files though, and can't find a way to do this without writing a custom parser for ansible formatted inventory files. Is there an API or just an ansible command I could run within ruby to get this hostlist?

Answer Source

If you really just need the list of inventory hosts (and not any of the other info), you can do:

ansible all -i (your inventory file here) --list-hosts
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download