0
votes

the following ansible 2.1.1.0 command hangs:

ansible@ansible:~/playbooks/APS/test$  ansible -vvv 10.162.38.161 -m ping -i /home/ansible/playbooks/APS/inventory/inventory.cfg
Using /etc/ansible/ansible.cfg as config file
<10.162.38.161> ESTABLISH SSH CONNECTION FOR USER: jboss
<10.162.38.161> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jboss -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/ansible-ssh-%h-%p-%r 10.162.38.161 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1471958265.1-43986661132468 `" && echo ansible-tmp-1471958265.1-43986661132468="` echo $HOME/.ansible/tmp/ansible-tmp-1471958265.1-43986661132468 `" ) && sleep 0'"'"''
<10.162.38.161> PUT /tmp/tmpYxsV4j TO /home/jboss/.ansible/tmp/ansible-tmp-1471958265.1-43986661132468/ping
<10.162.38.161> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jboss -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/ansible-ssh-%h-%p-%r '[10.162.38.161]'

On target machine

> tail -f /var/log/secure
Aug 23 16:07:16 xxx sshd[30368]: Accepted publickey for jboss from 10.162.8.163 port 57301 ssh2
Aug 23 16:07:16 xxx sshd[30368]: pam_unix(sshd:session): session opened for user jboss by (uid=0)
Aug 23 16:07:28 xxx sshd[30371]: subsystem request for sftp




I'm able to ping that target node

> ping 10.162.38.161
PING 10.162.38.161 (10.162.38.161) 56(84) bytes of data.
64 bytes from 10.162.38.161: icmp_seq=1 ttl=57 time=2.08 ms
64 bytes from 10.162.38.161: icmp_seq=2 ttl=57 time=2.77 ms

and to ssh without password

> ssh [email protected]
Last login: Tue Aug 23 15:19:37 2016 from 10.162.8.163
[jboss@xxxx ~]$

and sftp

> echo ciao >  ciao.txt
> sftp [email protected]
Connected to 10.162.38.161.
sftp> put ciao.txt
Uploading ciao.txt to /home/jboss/ciao.txt
ciao.txt  

UPDATE


I noticed that if I sftp big files, sftp does not work

> ansible -vvvv 10.162.38.161 -m setup 
... create /tmp/BIG_FILE

> sftp [email protected]
Connected to 10.162.38.161.
sftp> put BIG_FILE
Uploading BIG_FILE to /home/jboss/BIG_FILE
BIG_FILE                     0%    0     0.0KB/s - stalled -

I think that the problem is SFTP


Additional info:

Source: Ubuntu 14LTS
Target: Red Hat 4.4.7-11 - OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11Feb2013

This is source ssh_config:

Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes    
KeyRegenerationInterval 3600
ServerKeyBits 1024   
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes    
RSAAuthentication yes
PubkeyAuthentication yes    
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no    
PermitEmptyPasswords no
ChallengeResponseAuthentication no                    
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*   
Subsystem sftp /usr/lib/openssh/sftp-server

This is target sshd_config:

Protocol 2    
SyslogFacility AUTHPRIV    
PermitRootLogin yes    
PasswordAuthentication yes    
ChallengeResponseAuthentication no        
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes    
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES            
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS        
Subsystem       sftp    /usr/libexec/openssh/sftp-server
1
The last thing I see it doing is trying to connect with sftp. Can you confirm that you can put files on the remote host with sftp, and try editing your Ansible config and set scp_if_ssh = True? - MillerGeek
Added also SCP test. - Riccardo79
scp_if_ssh=true ... still hanging <10.162.38.161> SSH: EXEC scp -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jboss -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/ansible-ssh-%h-%p-%r /tmp/tmpSMDa4l '[10.162.38.161]:/home/jboss/.ansible/tmp/ansible-tmp-1471969122.04-65199019479647/setup' - Riccardo79
have you changed anything else in your Ansible config? If so, can you post it here? - MillerGeek
No everything is default. But, if I change target node, Ansible works. It seems something about that node... - Riccardo79

1 Answers

0
votes

First of all, I want to thanks @smiller171

After running ansible -vvvv 10.162.38.161 -m setup I noticed that the setup file on target machine was 0 bytes.

So I tried to SFTP one large file and I noticed that the process was STALLED.

The solution was to reduce MTU. I do not know why...

sudo ifconfig eth0 mtu 1490