use the '_meta' key http://docs.ansible.com/developing_inventory.html#tuning-the-external-inventory-script
On 21 April 2015 at 13:14, spezam <[email protected]> wrote: > 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 <hostname>. > > ["--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 > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/4858255e-6140-4f14-b7d7-1f8a45df1a34%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/4858255e-6140-4f14-b7d7-1f8a45df1a34%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEhzMJBa0m-ujYUE3rAJ5WGLYjiFS2DJ5vhjevtSR%3Dfyh0mPzQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
