this is dependent on implementation of the inventory scripts, they can return all host information with --list, if they do not ansible has to call them per host also.
On Wed, Dec 10, 2014 at 6:27 PM, Florin Andrei <[email protected]> wrote: > Okay, I placed both inventory scripts in ~/ansible/inventory and it works. > The command opens an ssh connection to each host on both clouds. > > But, again, spying the process tree list while ansible is running, I've > noticed something odd. (BTW, all runs are done after clearing the caches for > both inventory scripts every time) > > If I do -i ~/ansible/inventory/ec2.py, I see ansible running ec2.py --list > for a while, then it initiates the ssh connections. > > If I do -i ~/ansible/inventory/digital_ocean.py, I see ansible running > digital_ocean.py --list for a while, then digital_ocean.py --host once for > each host I have at DO, and then it launches the ssh connections. > > But if I do -i ~/ansible/inventory, I see this: It runs one of the scripts > with --list; it runs the other script with --list; then it runs > digital-ocean.py --host for all hosts in both lists (EC2 and DO)! This is A) > unnecessary, B) slow, and C) hammering the DO API servers for no good > reason. > > Is it a bug, or am I still doing something wrong? > > > On Wednesday, December 10, 2014 2:55:04 PM UTC-8, Matt Martz wrote: >> >> Ansible supports inventory directories. If you place both ec2.py and >> digital_ocean.py in a directory called "inventory", you could then use: >> >> ansible -i ~/ansible/inventory -u my-special-user -f 20 -s \* -m shell -a >> 'ps' >> >> You could then also call each inventory script separately if you needed. >> >> >> On Wed, Dec 10, 2014 at 4:48 PM, Florin Andrei <[email protected]> >> wrote: >>> >>> New to Ansible, just testing it. For now, I'm using dynamic inventory >>> scrips, and I'm trying to run simple commands on all hosts, via ansible. >>> >>> I've setup ec2.py and digital_ocean.py in ~/ansible/, and both scripts >>> work just fine. Provisioned with the correct credentials, if I run either >>> script manually, I get the correct list of assets from those two cloud >>> providers, respectively. >>> >>> If I run Ansible with just one script (either ec2.py or digital_ocean.py) >>> then that also works well: >>> >>> ansible -i ~/ansible/ec2.py -u my-special-user -f 20 -s \* -m shell -a >>> 'ps' >>> >>> ansible -i ~/ansible/digital_ocean.py -u my-special-user -f 20 -s \* -m >>> shell -a 'ps' >>> >>> But if I try to do just -i ~/ansible/ (hoping to use both inventory >>> scripts in a concatenated list) then it doesn't work. Spying the process >>> list with pstree, I've noticed that ansible runs digital_ocean.py --host >>> with all the hosts from the EC2 list. That can't be right. No wonder it >>> doesn't work then. >>> >>> What is the correct way to use several dynamic inventory scripts at once >>> for something simple like -m shell -a 'ps'? >>> >>> P.S.: >>> >>> If I run ./digital_ocean.py --list manually, it just throws a JSON with >>> my hosts. But if I do ./ec2.py --list manually, then it generates first the >>> "_meta": tag, and then throws a list similar to the DO script. Not sure if >>> this is relevant to the main issue, I just thought I should mention it. >>> >>> -- >>> 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/f1717237-2b88-4b50-b42d-b19f0ae8964a%40googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >> >> >> >> >> -- >> Matt Martz >> @sivel >> sivel.net > > -- > 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/b7212e8a-d587-40a1-b1ed-fe819e01c5a3%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- Brian Coca -- 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/CAJ5XC8mM6xQ%3D3YDPPFeYXCzLZnAbXjouFmfqcGvazUnMXsiKiw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
