Open juresaht2 opened 1 year ago
@juresaht2 - the snippet from docs in your description doesn't match the actual documentation at that location:
{
# results of inventory script as above go here
# ...
"_meta": {
"hostvars": {
"host001": {
"var001" : "value"
},
"host002": {
"var002": "value"
}
}
}
}
Have you tried this ^^ to see if it works?
I guess... you didn't read the entire document on the link? Or something?
The example you provided only shows how to use _meta
. What is required is a skeleton of the entire structure so that the inventory can be provided. Simply providing _meta
without defining at least one group, such as all
does not work.
This is what the document actually says, and the skeleton provided for it is the example I provided, which does not work.
The skeleton JSON object documented in: https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html#tuning-the-external-inventory-script
...doesn't seem to work when a inventory script outputs it.
It's hard to figure out what exactly is happening from just interpreting the debugging output while learning how to do this, but it looks like it's trying to load hosts as groups and does not parse the hostvars.
I was able to get things working using the structure documented in: https://github.com/geerlingguy/ansible-for-devops/blob/master/dynamic-inventory/custom/inventory.php
I saw some old bugs opened on this topic, but since those were fixed a long time ago, I assume that in the recent versions of Ansible something about this has changed and the structure provided in the documentation no longer really works and the documentation hasn't been updated.