Make sure your ssh host is added to the known host prior to executing any ssh 
command, the do you want to add the host [yes, no] question might be blocking 
you and await user interaction… which in case of automated system is not great.

From: [email protected] <[email protected]> On 
Behalf Of Shifa Shaikh
Sent: November 4, 2020 7:58 AM
To: Jenkins Users <[email protected]>
Subject: Ansible constructs ssh command that hangs and never returns.


I trigger the below ansible playbook using Jenkins pipeline.

- name: Play 2- Configure Source nodes

  hosts: "{{ location }}"

  user: remoteuser

  strategy: free

  gather_facts: false

  vars:

    ansible_ssh_extra_args: -o StrictHostKeyChecking=no -o ConnectionAttempts=5

    ansible_ssh_private_key_file: /app/automation/id_rsa



  tasks:



    - name: Execute script

      shell: "/app/mybkp.sh"

The above ansible-playbook is run as below in debug mode:

ansible-playbook orabackup.yml_final -i ora.hosts -f 90 -e location=MYIP -e 
ansible_ssh_use_tty=no -vvv

Below is the output where the Jenkins freezes and never completes.

PLAY [Play 2- Configure Source nodes] ******************************************

META: ran handlers

<10.0.0.111> Attempting python interpreter discovery

<10.0.0.111> ESTABLISH SSH CONNECTION FOR USER: remoteuser

<10.0.0.111> SSH: EXEC ssh -o 'IdentityFile="/app/automation/id_rsa"' -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o 'User="remoteuser"' -o ConnectTimeout=10 -o 
StrictHostKeyChecking=no -o ConnectionAttempts=5 10.0.0.111 '/bin/sh -c 
'"'"'echo PLATFORM; uname; echo FOUND; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.5'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''

<10.0.0.111> (0, 'PLATFORM

AIX

FOUND

/usr/bin/python3

ENDFOUND

', 'This system is for the use of authorized users only. Individuals using this 
computer system without authority, or in excess of their authority, are subject 
to having all of their activities on this system monitored and recorded by 
system personnel. In the course of monitoring individuals improperly using this 
system, or in the course of system maintenance, the activities of authorized 
users may also be monitored. Anyone using this system expressly consents to 
such monitoring and is advised that if such such monitoring reveals possible 
evidence of criminal activity, system personnel may provide the evidence of 
such monitoring to the law enforcement officials

')

<10.0.0.111> Python interpreter discovery fallback (unsupported platform for 
extended discovery: aix)

Using module file 
/usr/lib/python2.7/site-packages/ansible/modules/commands/command.py

Pipelining is enabled.

<10.0.0.111> ESTABLISH SSH CONNECTION FOR USER: remoteuser



<10.0.0.111> SSH: EXEC ssh -o 'IdentityFile="/app/automation/id_rsa"' -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o 'User="remoteuser"' -o ConnectTimeout=10 -o 
StrictHostKeyChecking=no -o ConnectionAttempts=5 10.0.0.111 '/bin/sh -c 
'"'"'/usr/bin/python3 && sleep 0'"'"''



The ssh constructed by ansible as visible in Jenkins log above, when executed 
manually in putty terminal also freezes / hangs and never returns.



This issue does not happen with other IPs but is specific to this IP 10.0.0.111



I removed  '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"'' from the ssh 
command, tried manually and it worked !!



I have uploaded the working ssh without  '/bin/sh -c '"'"'/usr/bin/python3 && 
sleep 0'"'"'' in debug mode here: 
https://drive.google.com/file/d/1MGWpWK2IeWa_LlifixrLTCwxv1IfvH2t/view?usp=sharing



I have uploaded the failed(freezing) ssh with  '/bin/sh -c 
'"'"'/usr/bin/python3 && sleep 0'"'"'' here: 
https://drive.google.com/file/d/1yXictTMKfNDqu4wqQejyt5TVM483v7s2/view?usp=sharing



Further, even '/bin/sh' hangs when i try



ssh -o 'IdentityFile="/app/automation/id_rsa"' -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o 'User="remoteuser"' -o ConnectTimeout=10 -o 
StrictHostKeyChecking=no -o ConnectionAttempts=5 10.0.0.111 '/bin/sh'



The target server 10.0.0.111 is AiX 6.1.



Can you please suggest how do I resolve this issue?
--
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0261d1f4-ac2c-4cde-bc8a-ca1b70598e37o%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/0261d1f4-ac2c-4cde-bc8a-ca1b70598e37o%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB3844BF4922CBC6D971684FA3CDEE0%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.

Reply via email to