MrDuk MrDuk - 10 months ago 82
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?


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