To clarify my question, when Ansible calls a dynamic inventory script that 
reads in a password, for example:

    #!/bin/sh

    read -s cmdb_password
    echo $cmdb_password > /tmp/test.out

    cat /tmp/test.json

I find that when I run Ansible, it is waiting for input.  I give it a line 
of input and then it is still waiting for input!  Then I give it a second 
line of input, and then it keeps going.  The second line is what gets 
logged to /tmp/test.out.  

What's going on?  Where does the first line go?

Here is how I test:

     ( echo one; echo two) | ansible -i ./test.sh all --list-hosts

I find the string "two" in my log file /tmp/test.out

Best,
-at

On Thursday, April 14, 2016 at 7:09:01 AM UTC-7, Aleksey Tsalolikhin wrote:
>
> Hello,
>
> I'm feeding Ansible 2.0.0.2 dynamic inventory from an enterprise CMDB 
> system.
>
> I've worked through two issues already:
>
> - inject empty _meta hostvars to be able to read in large JSON objects 
> without killing RAM & CPU  (
> https://groups.google.com/forum/#!searchin/Ansible-project/tsalolikhin/ansible-project/AB997vCLtCY/MT3CxG-fCAAJ
> )
> - filter CMDB output to remove records that don't have IP addresses as it 
> makes Ansible throw Python errors
>
> I think the last issue is allow the users to authenticate into the CMDB 
> system...
>
> I am trying to set it up so that the user would type their password into 
> STDIN for the dynamic inventory script...  what's strange is that I can 
> enter TWO lines and the first one isn't passed to the script...  what's 
> going on here?
>  
> $ cat test.sh
> #!/bin/sh
>
> read -s cmdb_password
>
> # pretend to download data from CMDB
> cat /tmp/test.json
>
> # and let's see what was entered
> echo $cmdb_password > /tmp/test.out
> $ ( echo one; echo two) | ansible -i ./test.sh all --list-hosts
>   hosts (1):
>     10.10.10.10
> $ cat /tmp/test.out
> two
> $
>
> Question:  What happened to "one" ?
>
> I was hoping to use a wrapper that would prompt the user for their CMDB 
> password and then start Ansible so that when they type in their password it 
> would go to the dynamic inventory script.
>
> Best,
> -at
>
>

-- 
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/961d8cbc-09e9-460f-bb39-9350b34e9ed6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to