Can the -i option of dynamic inventory accept a json directly instead of a executable file ?

46 views
Skip to first unread message

Ritesh Shetty

unread,
May 14, 2015, 2:23:30 PM5/14/15
to ansible...@googlegroups.com
My need is to call the ansible playbook with dynamic inventory and this inventory script needs to accept arguments . so depending on arguments the hosts will be different. I searched through the forrum and looks like the only option is to export variable which might not be a good idea in my case. 
So now i am trying to get the json out of a script by explicitly calling a custom method in dynamic inventory script and then trying to send this json to the playbook

Can the -i option of dynamic inventory accept a json directly instead of a executable file ?
I tried it and it doesnt work. I am using 1.8.2 


Matt Martz

unread,
May 14, 2015, 2:42:42 PM5/14/15
to ansible...@googlegroups.com
As your test indicated, the answer is no.  You could create an executable script that just cats out the JSON though.

--
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/2e89f96f-a8f5-48a2-bd17-d3a8462f6751%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Andrea Tartaglia

unread,
May 14, 2015, 3:15:25 PM5/14/15
to ansible...@googlegroups.com
Hi,

no unfortunatelyou cannot pass any variable to the dynamic inventory, it will be called automatically by ansible with the host or list argument. 
The only way you have is either setting env variables or having a config file. 



--
Andrea

----- Reply message -----
From: "Ritesh Shetty" <ritesh....@gmail.com>
To: <ansible...@googlegroups.com>
Subject: [ansible-project] Can the -i option of dynamic inventory accept a json directly instead of a executable file ?
Date: Thu, May 14, 2015 7:23 PM
Reply all
Reply to author
Forward
0 new messages