Ansible hangs when calling a script that runs commands over ssh

36 views
Skip to first unread message

6MT

unread,
Nov 25, 2017, 11:56:07 PM11/25/17
to Ansible Project
Hi all,

I have a script on a remote machine that ssh's into other machines to do stuff.

On the control machine, if I use the command or shell module to execute the script, everything works fine if the script is as simple as:

#!/bin/sh

echo "hi"

When the playbook is run, I get "hi" in stdout as expected.

However, when I change the script to:

#!/bin/sh

ssh somehost "echo hi"

Ansible hangs indefinitely.  If I put things in the background, e.g. nohup ssh somehost "echo hi" &, I get no output period.  

I've tried all sorts of redirecting stdin/stdout, etc and cannot seem to get this to work.

Has anyone run across this?  Your help is much appreciated.

Thanks

Pshem Kowalczyk

unread,
Nov 26, 2017, 2:14:39 AM11/26/17
to ansible...@googlegroups.com
Hi,

Are you sure you have key-based ssh setup correctly on the remote machine? Can ansible user find and access the ssh key required? Are you using the right user on the remote machine to ssh to the other machine? Is the public SSH key of the other machine already in know hosts (or are you ignoring those keys)?

kind regards
Pshem


--
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/4b327f63-4d60-4ebe-8a65-21bf8775ede4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

6MT

unread,
Nov 26, 2017, 3:04:17 AM11/26/17
to Ansible Project
Yes, I am positive.  From the control machine, I am able to do ssh <somehost> "test.sh" with the expected result of hi.

For some reason, when ansible calls a shell script that executes remote ssh commands, the script is not returning.

Pshem Kowalczyk

unread,
Nov 27, 2017, 2:50:19 AM11/27/17
to ansible...@googlegroups.com
The only thing left in those circumstances is to debug ansible:

1. Run with ANSIBLE_KEEP_REMOTE_FILES=1 environmental variable
2. SSH to the remote host and look in ~/.ansible/tmp - you'll find the actual python script that runs the module there. 
3. Inside that script there's command to 'explode'  the script into multiple files.
4. Once extracted - try to run it manually and see what happens.
5. Dive into code and see if you can figure out what's happening there.


kind regards
Pshem


--
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.
Reply all
Reply to author
Forward
0 new messages