Do dynamic inventories support command line arguments?

80 views
Skip to first unread message

george hartzell

unread,
Oct 27, 2015, 11:37:07 AM10/27/15
to Ansible Project
Hi All,
At http://docs.ansible.com/ansible/intro_dynamic_inventory.html, about halfway down, there's an example that reads:

ansible-playbook -i 'ec2.py --profile prod' myplaybook.yml

which suggests that it's possible to pass arguments to dynamic inventory programs.

In real life, I can't seem to get it to work. Is the just a bad example or is there a trick that I'm missing?

Thanks,

g.

Matt Martz

unread,
Oct 27, 2015, 12:27:08 PM10/27/15
to ansible...@googlegroups.com
That should not be possible.  I would say that is a bad example.


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/40231284-67a7-4eb0-a17e-9d243bbee532%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

esco real

unread,
Oct 27, 2015, 1:13:06 PM10/27/15
to Ansible Project
You could use some wrapper script(s) as inventory source for that..

Nirav Radia

unread,
Sep 8, 2016, 11:29:07 AM9/8/16
to Ansible Project
@esco real : The question remains the same. How to pass a command line argument to that wrapper script then?

Matt Martz

unread,
Sep 8, 2016, 11:50:06 AM9/8/16
to ansible...@googlegroups.com
You don't.  As of now, the recommended way to provide configuration to an inventory script is either via configuration file, or via environment variables.

As of now, there is no way to pass arguments directly to a dynamic inventory script.

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/80481788-6952-4cb8-90be-459b6d629b9e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Josh Smift

unread,
Sep 8, 2016, 12:13:57 PM9/8/16
to ansible...@googlegroups.com
MM> As of now, the recommended way to provide configuration to an
MM> inventory script is either via configuration file, or via environment
MM> variables.
MM>
MM> As of now, there is no way to pass arguments directly to a dynamic
MM> inventory script.

We've done things like this by having a default 'hosts' wrapper script
that calls our dynamic inventory script, and then other wrapper scripts
that call the dynamic inventory script with arguments, so you can add
'--inventory other-wrapper' or prefix 'ANSIBLE_HOSTS=other-wrapper' to get
the other wrapper, which passes along the command line argument.

If you want to be able to specify an arbitrary argument on the command
line on the fly, that won't work; but if you've got a few typical
command-line arguments you want to pass, something like this can work.

-Josh (j...@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Reply all
Reply to author
Forward
0 new messages