Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm attempting to do an Ansible ping ansible all -m ping --ask-pass but I get SSH failures. As the debug log is rather extensive, I've trimmed down the below quote to where I think the problem occurs. Earlier in the log, I am able to connect to the remote host (a headless RHEL5 VM) but when actually executing the "ping", it fails with the below error(s).

debug1: Entering interactive session.
debug2: set_control_persist_exit_time: schedule exit in 60 seconds
debug1: multiplexing control connection
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 1: new [mux-control]
debug3: channel_post_mux_listener: new mux channel 1 fd 5
debug3: mux_master_read_cb: channel 1: hello sent
debug2: set_control_persist_exit_time: cancel scheduled exit
debug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4
debug2: process_mux_master_hello: channel 1 slave version 4
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4
debug2: process_mux_alive_check: channel 1: alive check
debug3: mux_client_request_alive: done pid = 9664
debug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 264
debug2: process_mux_new_session: channel 1: request tty 1, X 0, agent 0, subsys 0, term "xterm", cmd "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459 && echo $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459'", env 0
debug3: mux_client_request_session: session request sent
mm_receive_fd: no message header
process_mux_new_session: failed to receive fd 0 from slave
debug1: channel 1: mux_rcb failed
debug2: channel 1: zombie
debug2: channel 1: gc: notify user
debug3: mux_master_control_cleanup_cb: entering for channel 1
debug2: channel 1: gc: user detached
debug2: channel 1: zombie
debug2: channel 1: garbage collecting
debug1: channel 1: free: mux-control, nchannels 2
debug3: channel 1: status: The following connections are open:

I connected by conventional SSH to the host machine then checked to see if xterm runs on the remote box and while it's installed. It runs but bombs out with the following error:

xterm Xt error: Can't open display:
xterm:  DISPLAY is not set

My hunch is that ssh connects, attempts to run the commands then can't because xterm bombs out. I've gone looking for a way to change which terminal to use but haven't been able to find anything in the documentation. Any input or suggestions are greatly appreciated.

share|improve this question
    
ssh -X perhaps? "-X Enables X11 forwarding. This can also be specified on a per host basis in a configuration file." –  Cristian Ciupitu Feb 11 at 15:31
add comment

3 Answers 3

up vote 3 down vote accepted

As of this writing, there's something weird about running Ansible in Cygwin on Windows. Not sure what it is but it's not anything I can fix. I switched over to a Linux VM and things have started to work properly.

share|improve this answer
add comment

I got it working on cygin with some 2 hours of googling freaky errors with the following set-up:

cat /etc/ansible/ansible.cfg
[defaults]
host_key_checking = False

probably bad for security ..., also:

 cat /etc/ansible/hosts
 [dbservers]
 56.77.50.151   ansible_ssh_port=22     ansible_ssh_user=ssh_user

verify:

ansible -vvvv all -a "/bin/echo hello"

I had to make sure that public private key authentication is configured correctly

cat id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/authorized_keys
chmod 0600  ~/.ssh/authorized_keys
ls -al ~/.ssh/authorized_keys
rm -fv ~/id_rsa.pub

I would suspect the turning point for the configuration for groups and users on cygwin: and chown -v local_pc_user:local_pc_user ~/.ssh/id_rsa.pub

and finally the output is:

    <56.77.50.151> ESTABLISH CONNECTION FOR USER: ssh_user
    <56.77.50.151> REMOTE_MODULE command /bin/echo hello
    <56.77.50.151> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o',
    'ControlPath=/home/local_pc_user/.ansible/cp/ansible-ssh-%h-%p-%r',
    '-o', 'StrictHostKeyChecking=no', '-o', 
    'Port=22', '-o', 'KbdInteractiveAuthentication=no',
    '-o', 'PreferredAuthentications=gssapi-with-mic,
    gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ssh_user', '-o', 'ConnectTimeout=10',
    '56.77.50.151', "/bin/sh -c 'mkdir -p
    $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280 &&
    chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280 &&
    echo $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280'"]
    <56.77.50.151> PUT /tmp/tmprELaVU TO /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/command
    <56.77.50.151> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto',
    '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/local_pc_user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22',
    '-o', 'KbdInteractiveAuthentication=no', '-o', 
    'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ssh_user', '-o', 'ConnectTimeout=10'
    , '56.77.50.151', "/bin/sh -c '/usr/bin/python 
    /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/command; 
    rm -rf /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/ 
    >/dev/null 2>&1'"]
    56.77.50.151 | success | rc=0 >>
    hello
share|improve this answer
add comment

This behaviour started after some Ansible update. In older Ansible versions I had no problems with it. It indeed seems to be xterm that is the problem. Why would Ansible need to run xterm? I'd class it as a bug in Ansible.

Anyway, I worked around the issue in Cygwin by adding the following to ~/.ssh/config:

ForwardX11 yes
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.