Hello,
I’m trying to develop a script for dynamic inventory, following this (poor) documentation
http://docs.ansible.com/developing_inventory.html
I tested the script with the command
ansible --list-hosts database
which works fine and return the database hosts.
I logged the calls to the script and I can see the first call made by ansible (–list) outputs the list of hosts and their groups
{ "database": { "hosts": [ "host1", "host2" ] }, "apache": { "hosts": [ "host3", "host4" ] } }
Ansible then iterates through all the hosts and call the script with --host .
[“–list”]
[“–host”, “host1”]
[“–host”, “host2”]
[“–host”, “host3”]
[“–host”, “host4”]
The performance problem obviously appears when the list of hosts and groups grows.
While I expect the ‘–host’ call to be done only on the database hosts, it seems ansible is iterating through the full catalog.
Is that expected? Any way I can avoid this behavior?
Thanks,
Matteo