Since ansible already supports caching of facts shouldn’t this also be a job of ansible itself? Otherwise each dynamic inventory plugin will implement it in a different way or not implement it at all…
You’ve hit the nail on the head! We do have plans to make a ‘inventory cache’ part of Ansible itself, currently its up to each script and of course we have different implementations and some that don’t implement any.
You’ve hit the nail on the head! We do have plans to make a ‘inventory cache’ part of Ansible itself, currently its up to each script and of course we have different implementations and some that don’t implement any.
While we don’t have a global inventory cache, I’m saving the dynamic inv script output to a file, and using it between ansible runs. In order for this to work I have a hack which is an executable script that the only thing it does it “cat output.json”. Is there a better way? Can ansible read directly the hosts from the json file or ir there a way to convert this json to the format ansible understands?
This is an old thread, but has this support been added to inventory script? My initial testing indicates that it is not doing any caching, but perhaps I’m missing a setting. I added in my .ansible.cfg the following:
[inventory_plugin_script]
cache=yes
However, I don’t see the inventory being cached at all.
This is a bug, the 'inventory cache' was originally added in 2.4 but
we had to remove it due to some issues. We have added it back in 2.5
but forgot to update the script plugin to handle it also (or just
remove the docs that says it is supported).