`--no-vars` option for `ansible-inventory(1)`?

Hi!

I’m using ansible-inventory --list to get a parsed view of the inventory¹.

Unfortunately, it does too much: it also outputs a huge (8 MB compared to maybe a dozen KB for the inventory) key called _meta which I have to immediately throw away again because I’m not interested.

I looked into whether I could use the Python3 API directly, but the docs say it’s internal and paws away.

So, this would not be a problem (I can just throw away that subkey)… except, to output that part, it needs the vault password.

I didn’t even notice because I have a thing that decrypts the vault password using ssh-agent automatically when needed (blogpost (in English) on that coming), but others have not yet set that up and did notice, so I added --ask-vault-pass for now.

Could please an option like --no-vars or --no-meta be added to the ansible-inventory(1) tool so that it just… doesn’t do that?

Having looked at the source, that would be an addition of… maybe three lines or so (plus indenting change).


① This is for a verification tool that checks things like, every host has exactly one host playbook xor one group playbook; every host playbook handles exactly one host; every host is in the inventory; every group playbook handles exactly one group; warn if hosts in the inventory have neither host nor group playbook; check host and group names against an RE; generate a “master playbook” that imports all others; etc. — it’s probably very specific to one certain (possibly suboptimal but historically grown) repo layout, but if there is interest, I could probably share it, I’d have to ask but experience tells me chances are good.

(on that matter, it would be nice if the format was actually documented in the manpage and documented as stable, and if other tools outputting similar informations, like ansible-playbook --list-hosts, also had stable, documented, script-parseable output, at least with an option like --batch or so, no need to change the existing output if such an option is not given)