Ansible unhandled error in python interpreter discovery for host

SUMMARY We operate Packer builds through Jenkins, and those Packer builds use Ansible provisioners. We recently upgraded from Ansible 2.7 to 2.8 and started to experience indefinitely hanging build...
SUMMARY

We operate Packer builds through Jenkins, and those Packer builds use Ansible provisioners. We recently upgraded from Ansible 2.7 to 2.8 and started to experience indefinitely hanging builds on the «Gathering Facts» step. Further investigation narrowed it down to a hanging ssh command as part of the «Attempting python interpreter discovery» step.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Interpreter Discovery

ANSIBLE VERSION
ansible --version
ansible 2.8.0
  config file = None
  configured module search path = [u'/home/centos/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr  9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
CONFIGURATION
OS / ENVIRONMENT

The machine running Packer: CentOS Linux release 7.6.1810 (Core)
Packer version is 0.12.1

STEPS TO REPRODUCE

I am not certain that it’s related, but we are using SSH agent to provide SSH keys to Packer, and through to Ansible.

packer build example.json

The example.json:

{
  "builders": [
    {
      "type": "amazon-ebs",
      "region": "us-east-1",
      "source_ami": "ami-4bf3d731",
      "instance_type": "t2.micro",
      "ssh_username": "centos",
      "ami_name": "ansible bug report {{timestamp}}",
      "ssh_keypair_name": "ansible-dev",
      "ssh_agent_auth": true,
      "tags": {
        "AutoCleanUp": true
      },
      "communicator": "ssh",
      "ssh_pty": true
    }
  ],
  "provisioners": [
    {
      "type": "ansible",
      "extra_arguments": ["-vvvv"],
      "playbook_file": "../ansible_bug_report.yml"
    }
  ]
}

The referenced playbook:

---
- name: ansible bug report
  hosts: all
  become: yes

  tasks:
    - debug:
        msg: "hello"
EXPECTED RESULTS

The build succeeds and an AMI is produced using the Ansible provisioner.

ACTUAL RESULTS

The build hangs on the «Gathering Facts» step. Looking at the process tree, Ansible appears to be SSHing into localhost in order to determine the Python interpreter path.

Full command output from Packer:

14:32:21 amazon-ebs output will be in this color.
14:32:21 
14:32:22 ==> amazon-ebs: Prevalidating AMI Name...
14:32:24     amazon-ebs: Found Image ID: ami-4bf3d731
14:32:24 ==> amazon-ebs: Using SSH Agent for existing key pair ansible-dev
14:32:24 ==> amazon-ebs: Launching a source AWS instance...
14:32:30     amazon-ebs: Instance ID: i-03a846ae9ad775673
14:32:30 ==> amazon-ebs: Waiting for instance (i-03a846ae9ad775673) to become ready...
14:32:58 ==> amazon-ebs: Waiting for SSH to become available...
14:33:30 ==> amazon-ebs: Connected to SSH!
14:33:30 ==> amazon-ebs: Provisioning with Ansible...
14:33:31     amazon-ebs: ansible-playbook 2.8.0
14:33:31     amazon-ebs:   config file = None
14:33:31     amazon-ebs:   configured module search path = [u'/home/centos/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
14:33:31     amazon-ebs:   ansible python module location = /usr/lib/python2.7/site-packages/ansible
14:33:31     amazon-ebs:   executable location = /usr/bin/ansible-playbook
14:33:31     amazon-ebs:   python version = 2.7.5 (default, Apr  9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
14:33:31     amazon-ebs: No config file found; using defaults
14:33:31     amazon-ebs: setting up inventory plugins
14:33:31     amazon-ebs: host_list declined parsing /tmp/packer-provisioner-ansible840704494 as it did not pass it's verify_file() method
14:33:31     amazon-ebs: script declined parsing /tmp/packer-provisioner-ansible840704494 as it did not pass it's verify_file() method
14:33:31     amazon-ebs: auto declined parsing /tmp/packer-provisioner-ansible840704494 as it did not pass it's verify_file() method
14:33:31     amazon-ebs: Parsed /tmp/packer-provisioner-ansible840704494 inventory source with ini plugin
14:33:32     amazon-ebs: Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc
14:33:32     amazon-ebs:
14:33:32     amazon-ebs: PLAYBOOK: ansible_bug_report.yml ***********************************************
14:33:32     amazon-ebs: Positional arguments: /home/centos/workspace/Andrei AWS AMI/ansible_bug_report.yml
14:33:32     amazon-ebs: private_key_file: /tmp/ansible-key953728523
14:33:32     amazon-ebs: become_method: sudo
14:33:32     amazon-ebs: inventory: (u'/tmp/packer-provisioner-ansible840704494',)
14:33:32     amazon-ebs: forks: 5
14:33:32     amazon-ebs: tags: (u'all',)
14:33:32     amazon-ebs: verbosity: 4
14:33:32     amazon-ebs: connection: smart
14:33:32     amazon-ebs: timeout: 10
14:33:32     amazon-ebs: 1 plays in /home/centos/workspace/Andrei AWS AMI/ansible_bug_report.yml
14:33:32     amazon-ebs:
14:33:32     amazon-ebs: PLAY [ansible bug report] ******************************************************
14:33:32     amazon-ebs:
14:33:32     amazon-ebs: TASK [Gathering Facts] *********************************************************
14:33:32     amazon-ebs: task path: /home/centos/workspace/Andrei AWS AMI/ansible_bug_report.yml:2
14:33:32     amazon-ebs: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: centos
14:33:32     amazon-ebs: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=36805 -o 'IdentityFile="/tmp/ansible-key953728523"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="centos"' -o ConnectTimeout=10 -o ControlPath=/home/centos/.ansible/cp/81401c3b4b 127.0.0.1 '/bin/sh -c '"'"'echo ~centos && sleep 0'"'"''
14:33:33     amazon-ebs: <127.0.0.1> (0, '/home/centosrn', 'OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017rndebug1: Reading configuration data /etc/ssh/ssh_configrndebug1: /etc/ssh/ssh_config line 58: Applying options for *rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/centos/.ansible/cp/81401c3b4b" does not existrndebug2: resolving "127.0.0.1" port 36805rndebug2: ssh_connect_direct: needpriv 0rndebug1: Connecting to 127.0.0.1 [127.0.0.1] port 36805.rndebug2: fd 3 setting O_NONBLOCKrndebug1: fd 3 clearing O_NONBLOCKrndebug1: Connection established.rndebug3: timeout: 10000 ms remain after connectrndebug1: key_load_public: No such file or directoryrndebug1: identity file /tmp/ansible-key953728523 type -1rndebug1: key_load_public: No such file or directoryrndebug1: identity file /tmp/ansible-key953728523-cert type -1rndebug1: Enabling compatibility mode for protocol 2.0rndebug1: Local version string SSH-2.0-OpenSSH_7.4rndebug1: Remote protocol version 2.0, remote software version Gorndebug1: no match: Gorndebug2: fd 3 setting O_NONBLOCKrndebug1: Authenticating to 127.0.0.1:36805 as 'centos'rndebug3: put_host_port: [127.0.0.1]:36805rndebug3: hostkeys_foreach: reading file "/home/centos/.ssh/known_hosts"rndebug3: send packet: type 20rndebug1: SSH2_MSG_KEXINIT sentrndebug3: receive packet: type 20rndebug1: SSH2_MSG_KEXINIT receivedrndebug2: local client KEXINIT proposalrndebug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-crndebug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dssrndebug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbcrndebug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbcrndebug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1rndebug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1rndebug2: compression ctos: zlib@openssh.com,zlib,nonerndebug2: compression stoc: zlib@openssh.com,zlib,nonerndebug2: languages ctos: rndebug2: languages stoc: rndebug2: first_kex_follows 0 rndebug2: reserved 0 rndebug2: peer server KEXINIT proposalrndebug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1rndebug2: host key algorithms: ssh-rsarndebug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128rndebug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128rndebug2: MACs ctos: hmac-sha2-256,hmac-sha1,hmac-sha1-96rndebug2: MACs stoc: hmac-sha2-256,hmac-sha1,hmac-sha1-96rndebug2: compression ctos: nonerndebug2: compression stoc: nonerndebug2: languages ctos: rndebug2: languages stoc: rndebug2: first_kex_follows 0 rndebug2: reserved 0 rndebug1: kex: algorithm: curve25519-sha256@libssh.orgrndebug1: kex: host key algorithm: ssh-rsarndebug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: nonerndebug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: nonerndebug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32rndebug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32rndebug3: send packet: type 30rndebug1: expecting SSH2_MSG_KEX_ECDH_REPLYrndebug3: receive packet: type 31rndebug1: Server host key: ssh-rsa SHA256:Qrzbyttftyr6ukAD6EA47RTmilrno5klbpgN0qGBREwrndebug3: put_host_port: [127.0.0.1]:36805rndebug3: put_host_port: [127.0.0.1]:36805rndebug3: hostkeys_foreach: reading file "/home/centos/.ssh/known_hosts"rndebug1: checking without port identifierrndebug3: hostkeys_foreach: reading file "/home/centos/.ssh/known_hosts"rnWarning: Permanently added '[127.0.0.1]:36805' (RSA) to the list of known hosts.rndebug3: send packet: type 21rndebug2: set_newkeys: mode 1rndebug1: rekey after 4294967296 blocksrndebug1: SSH2_MSG_NEWKEYS sentrndebug1: expecting SSH2_MSG_NEWKEYSrndebug3: receive packet: type 21rndebug1: SSH2_MSG_NEWKEYS receivedrndebug2: set_newkeys: mode 0rndebug1: rekey after 4294967296 blocksrndebug2: key: /home/centos/workspace/Andrei AWS AMI@tmp/private_key_4343293818745414027.key (0x56446565ffe0), agentrndebug2: key: /tmp/ansible-key953728523 ((nil)), explicitrndebug3: send packet: type 5rndebug3: receive packet: type 6rndebug2: service_accept: ssh-userauthrndebug1: SSH2_MSG_SERVICE_ACCEPT receivedrndebug3: send packet: type 50rndebug3: receive packet: type 51rndebug1: Authentications that can continue: publickeyrndebug3: start over, passed a different list publickeyrndebug3: preferred gssapi-with-mic,gssapi-keyex,hostbased,publickeyrndebug3: authmethod_lookup publickeyrndebug3: remaining preferred: ,gssapi-keyex,hostbased,publickeyrndebug3: authmethod_is_enabled publickeyrndebug1: Next authentication method: publickeyrndebug1: Offering RSA public key: /home/centos/workspace/Andrei AWS AMI@tmp/private_key_4343293818745414027.keyrndebug3: send_pubkey_testrndebug3: send packet: type 50rndebug2: we sent a publickey packet, wait for replyrndebug3: receive packet: type 51rndebug1: Authentications that can continue: publickeyrndebug1: Trying private key: /tmp/ansible-key953728523rndebug3: sign_and_send_pubkey: RSA SHA256:JDxv9I++yF+XEDdEA8AjbzgYLsA1G9dBKNdKEZP22xMrndebug3: send packet: type 50rndebug2: we sent a publickey packet, wait for replyrndebug3: receive packet: type 52rndebug1: Authentication succeeded (publickey).rnAuthenticated to 127.0.0.1 ([127.0.0.1]:36805).rndebug1: setting up multiplex master socketrndebug3: muxserver_listen: temporary control path /home/centos/.ansible/cp/81401c3b4b.vEImnw3fwP2Gi8xcrndebug2: fd 5 setting O_NONBLOCKrndebug3: fd 5 is O_NONBLOCKrndebug3: fd 5 is O_NONBLOCKrndebug1: channel 0: new [/home/centos/.ansible/cp/81401c3b4b]rndebug3: muxserver_listen: mux listener channel 0 fd 5rndebug2: fd 3 setting TCP_NODELAYrndebug3: ssh_packet_set_tos: set IP_TOS 0x08rndebug1: control_persist_detach: backgrounding master processrndebug2: control_persist_detach: background process is 31013rndebug2: fd 5 setting O_NONBLOCKrndebug1: forking to backgroundrndebug1: Entering interactive session.rndebug1: pledge: idrndebug2: set_control_persist_exit_time: schedule exit in 60 secondsrndebug1: multiplexing control connectionrndebug2: fd 6 setting O_NONBLOCKrndebug3: fd 6 is O_NONBLOCKrndebug1: channel 1: new [mux-control]rndebug3: channel_post_mux_listener: new mux channel 1 fd 6rndebug3: mux_master_read_cb: channel 1: hello sentrndebug2: set_control_persist_exit_time: cancel scheduled exitrndebug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4rndebug2: process_mux_master_hello: channel 1 slave version 4rndebug2: mux_client_hello_exchange: master version 4rndebug3: mux_client_forwards: request forwardings: 0 local, 0 remoterndebug3: mux_client_request_session: enteringrndebug3: mux_client_request_alive: enteringrndebug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4rndebug2: process_mux_alive_check: channel 1: alive checkrndebug3: mux_client_request_alive: done pid = 31015rndebug3: mux_client_request_session: session request sentrndebug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 92rndebug2: process_mux_new_session: channel 1: request tty 0, X 0, agent 0, subsys 0, term "", cmd "/bin/sh -c 'echo ~centos && sleep 0'", env 1rndebug3: process_mux_new_session: got fds stdin 7, stdout 8, stderr 9rndebug2: fd 8 setting O_NONBLOCKrndebug2: fd 9 setting O_NONBLOCKrndebug1: channel 2: new [client-session]rndebug2: process_mux_new_session: channel_new: 2 linked to control channel 1rndebug2: channel 2: send openrndebug3: send packet: type 90rndebug3: receive packet: type 91rndebug2: callback startrndebug2: client_session2_setup: id 2rndebug1: Sending environment.rndebug1: Sending env LANG = en_US.UTF-8rndebug2: channel 2: request env confirm 0rndebug3: send packet: type 98rndebug1: Sending command: /bin/sh -c 'echo ~centos && sleep 0'rndebug2: channel 2: request exec confirm 1rndebug3: send packet: type 98rndebug3: mux_session_confirm: sending success replyrndebug2: callback donerndebug2: channel 2: open confirm rwindow 2097152 rmax 32768rndebug1: mux_client_request_session: master session id: 2rndebug3: receive packet: type 99rndebug2: channel_input_status_confirm: type 99 id 2rndebug2: exec request accepted on channel 2rndebug3: receive packet: type 98rndebug1: client_input_channel_req: channel 2 rtype exit-status reply 0rndebug3: mux_exit_message: channel 2: exit message, exitval 0rndebug3: receive packet: type 97rndebug2: channel 2: rcvd closerndebug2: channel 2: output open -> drainrndebug2: channel 2: close_readrndebug2: channel 2: input open -> closedrndebug3: channel 2: will not send data after closerndebug2: channel 2: obuf emptyrndebug2: channel 2: close_writerndebug2: channel 2: output drain -> closedrndebug2: channel 2: send closerndebug3: send packet: type 97rndebug2: channel 2: is deadrndebug2: channel 2: gc: notify userrndebug3: mux_master_session_cleanup_cb: entering for channel 2rndebug2: channel 1: rcvd closerndebug2: channel 1: output open -> drainrndebug2: channel 1: close_readrndebug2: channel 1: input open -> closedrndebug2: channel 2: gc: user detachedrndebug2: channel 2: is deadrndebug2: channel 2: garbage collectingrndebug1: channel 2: free: client-session, nchannels 3rndebug3: channel 2: status: The following connections are open:rn  #1 mux-control (t16 r-1 i3/0 o1/16 fd 6/6 cc -1)rn  #2 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)rnrndebug2: channel 1: obuf emptyrndebug2: channel 1: close_writerndebug2: channel 1: output drain -> closedrndebug2: channel 1: is dead (local)rndebug2: channel 1: gc: notify userrndebug3: mux_master_control_cleanup_cb: entering for channel 1rndebug2: channel 1: gc: user detachedrndebug2: channel 1: is dead (local)rndebug2: channel 1: garbage collectingrndebug1: channel 1: free: mux-control, nchannels 2rndebug3: channel 1: status: The following connections are open:rn  #1 mux-control (t16 r-1 i3/0 o3/0 fd 6/6 cc -1)rnrndebug2: set_control_persist_exit_time: schedule exit in 60 secondsrndebug3: mux_client_read_packet: read header failed: Broken piperndebug2: Received exit status from master 0rn')
14:33:33     amazon-ebs: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: centos
14:33:33     amazon-ebs: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=36805 -o 'IdentityFile="/tmp/ansible-key953728523"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="centos"' -o ConnectTimeout=10 -o ControlPath=/home/centos/.ansible/cp/81401c3b4b 127.0.0.1 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/centos/.ansible/tmp/ansible-tmp-1559918012.29-221707555486654 `" && echo ansible-tmp-1559918012.29-221707555486654="` echo /home/centos/.ansible/tmp/ansible-tmp-1559918012.29-221707555486654 `" ) && sleep 0'"'"''
14:33:33     amazon-ebs: <127.0.0.1> (0, 'ansible-tmp-1559918012.29-221707555486654=/home/centos/.ansible/tmp/ansible-tmp-1559918012.29-221707555486654rn', 'OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017rndebug1: Reading configuration data /etc/ssh/ssh_configrndebug1: /etc/ssh/ssh_config line 58: Applying options for *rndebug1: auto-mux: Trying existing masterrndebug2: fd 3 setting O_NONBLOCKrndebug2: mux_client_hello_exchange: master version 4rndebug3: mux_client_forwards: request forwardings: 0 local, 0 remoterndebug3: mux_client_request_session: enteringrndebug3: mux_client_request_alive: enteringrndebug3: mux_client_request_alive: done pid = 31015rndebug3: mux_client_request_session: session request sentrndebug1: mux_client_request_session: master session id: 2rndebug3: mux_client_read_packet: read header failed: Broken piperndebug2: Received exit status from master 0rn')
14:33:34     amazon-ebs: <default> Attempting python interpreter discovery
14:33:34     amazon-ebs: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: centos
14:33:34     amazon-ebs: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=36805 -o 'IdentityFile="/tmp/ansible-key953728523"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="centos"' -o ConnectTimeout=10 -o ControlPath=/home/centos/.ansible/cp/81401c3b4b 127.0.0.1 '/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'"'"''
14:33:34     amazon-ebs: <127.0.0.1> (0, 'PLATFORMrnLinuxrnFOUNDrn/usr/bin/pythonrn/usr/bin/python2.7rn/usr/bin/pythonrnENDFOUNDrn', 'OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017rndebug1: Reading configuration data /etc/ssh/ssh_configrndebug1: /etc/ssh/ssh_config line 58: Applying options for *rndebug1: auto-mux: Trying existing masterrndebug2: fd 3 setting O_NONBLOCKrndebug2: mux_client_hello_exchange: master version 4rndebug3: mux_client_forwards: request forwardings: 0 local, 0 remoterndebug3: mux_client_request_session: enteringrndebug3: mux_client_request_alive: enteringrndebug3: mux_client_request_alive: done pid = 31015rndebug3: mux_client_request_session: session request sentrndebug1: mux_client_request_session: master session id: 2rndebug3: mux_client_read_packet: read header failed: Broken piperndebug2: Received exit status from master 0rn')
14:33:34     amazon-ebs: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: centos
14:33:34     amazon-ebs: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=36805 -o 'IdentityFile="/tmp/ansible-key953728523"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="centos"' -o ConnectTimeout=10 -o ControlPath=/home/centos/.ansible/cp/81401c3b4b 127.0.0.1 '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''

As the build is hung, here is what the relevant part of the process tree looks like:

# from `ps auxf`
root      4104  0.0  0.3 112864  3432 ?        Ss   08:22   0:00 /usr/sbin/sshd -D
root      4123  0.0  0.3 156728  3932 ?        Ss   08:22   0:00  _ sshd: centos [priv]
centos    4127  0.0  0.2 157216  2548 ?        S    08:22   0:02  |   _ sshd: centos@notty
centos    4207  0.6 15.5 2354120 157112 ?      Ssl  08:22   2:18  |       _ java -jar /tmp/slave.jar
centos   30934  0.0  0.1 113176  1208 ?        S    14:32   0:00  |           _ /bin/bash /tmp/jenkins8140454134051856858.sh
centos   30935  0.1  1.0  34296 10720 ?        Sl   14:32   0:00  |               _ packer build example.json
centos   30939  0.0  0.9  32052  9716 ?        Sl   14:32   0:00  |                   _ /usr/local/bin/packer build example.json
centos   30943  0.0  1.4  34296 15016 ?        Sl   14:32   0:00  |                       _ /usr/local/bin/packer plugin packer-builder-amazon-ebs
centos   30957  0.3  1.2  34296 12556 ?        Sl   14:32   0:00  |                       _ /usr/local/bin/packer plugin packer-provisioner-ansible
centos   31000  2.9  4.6 372156 46884 ?        Rl   14:33   0:04  |                           _ /usr/bin/python2 /usr/bin/ansible-playbook /home/centos/workspace/Andrei AWS AMI/ansible_bug_report.yml -i /tmp/packer-provisioner-ansible840704494 --private-key /tmp/ansible-key953728523 -vvvv
centos   31011  0.2  4.5 377656 46488 ?        S    14:33   0:00  |                               _ /usr/bin/python2 /usr/bin/ansible-playbook /home/centos/workspace/Andrei AWS AMI/ansible_bug_report.yml -i /tmp/packer-provisioner-ansible840704494 --private-key /tmp/ansible-key953728523 -vvvv
centos   31018  0.0  0.3 178524  3480 ?        S    14:33   0:00  |                                   _ ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=36805 -o IdentityFile="/tmp/ansible-key953728523" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User="centos" -o ConnectTimeout=10 -o ControlPath=/home/centos/.ansible/cp/81401c3b4b 127.0.0.1 /bin/sh -c '/usr/bin/python && sleep 0'

Interestingly, if I kill the last pid 31018, the build moves forward and eventually succeeds. We are currently working around the problem by explicitly specifying the python interpreter: via the ansible_python_interpreter=/usr/bin/python extra argument into the Ansible provisioner.

I’ve followed the recommendations I could find to prevent this from happening. I am using Vagrant, but once the boxes are spun, I’d like to do things with the ansible command sometimes.

$ grep host_key /etc/ansible/ansible.cfg                                                                                                               
host_key_checking = False

$ grep kafka01 ./inventory
kafka01 ansible_host=127.0.0.1 ansible_port=2231 ansible_user='vagrant' ansible_ssh_private_key_file='/home/me/project/project/.vagrant/machines/kafka01/virtualbox/private_key' ansible_ssh_common_args='-o StrictHostKeyChecking=no'

$ export ANSIBLE_HOST_KEY_CHECKING=False
$ ansible kafka01 -m ping -i ./inventory                                                                                                               

 [WARNING]: Unhandled error in Python interpreter discovery for host kafka01: Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @    WARNING:
REMOTE HOST IDENTIFICATION HAS CHANGED!     @  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!  Someone could be eavesdropping on
you right now (man-in-the-middle attack)!  It is also possible that a host key has just been changed.  The fingerprint for the ECDSA key sent by the remote host is
SHA256:jn5ClU5g566Gsvobf8Xc45DJnIiAllN+RJkg35Nf9KE.  Please contact your system administrator.  Add correct host key in /home/me/.ssh/known_hosts to get rid of this message.  Offending ECDSA key
in /home/me/.ssh/known_hosts:19    remove with:    ssh-keygen -f "/home/me/.ssh/known_hosts" -R "[127.0.0.1]:2231"  ECDSA host key for [127.0.0.1]:2231 has changed and you have requested strict
checking.  Host key verification failed.

kafka01 | UNREACHABLE! => {
.....

What’s going on here?

Edit: No, I don’t want to keep deleting the key. I destroy/build these over and over again. I want to find the correct, long-term solution.

asked Apr 9, 2020 at 0:26

TacoVia - Shut up about Monica's user avatar

6

You can add this in inventory:

ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"

It’s ignoring check host and setting /dev/null as Known host file.

answered May 6, 2020 at 3:09

Dilson Rainov's user avatar

1

An alternative sintax to Dilson Rainov‘s answer, more ansible 2.x style (I think).

In your inventory define the host as:

vagrant-local:
      ansible_host: 192.168.33.10
      ansible_user: vagrant
      ansible_ssh_private_key_file: .vagrant/machines/default/virtualbox/private_key
      UserKnownHostsFile: /dev/null
      StrictHostKeyChecking: no
      ansible_python_interpreter: /usr/bin/python3
  • UserKnownHostsFile causes the check of the host fingerprint on an always empty file (replacing the check inside ~/.ssh/known_hosts)
  • StrictHostKeyChecking allows ssh to connect without the user confirming the detected fingerprint from the vagrant host

answered Sep 17, 2020 at 18:33

Lennonry's user avatar

This just started, and can’t explain why. Don’t know for sure if anything changed or not…

When doing basic ansible all -m ping and/or ansible all -m command -a «uptime» -o, for some reason one of the hosts (10.1.1.5) never responds and those ad-hoc commands hang until I press ctrl +c.

That host, I’m able to ping from my workstation along with sshing into it with no issues. So I know its up, responding to pings and able to ssh into it with no issues.

Here is my Ansible setup and the output from commands I’ve tried:

[user_a@host_a playbooks]$ ansible --version

ansible 2.9.19

config file = /etc/ansible/ansible.cfg

configured module search path = ['/home/user_a/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

ansible python module location = /usr/lib/python3.6/site-packages/ansible

executable location = /usr/bin/ansible

python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

[user_a@host_a playbooks]$ ansible all --list-hosts

hosts (4):

10.1.1.2

10.1.1.3

10.1.1.5

10.1.1.4

[user_a@host_a playbooks]$ ansible all -m ping

PLAY [Ansible Ad-Hoc] *********************************************************************************************************************************************************************************************

TASK [ping] *******************************************************************************************************************************************************************************************************

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.2: unexpected output from Python interpreter discovery

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.3: unexpected output from Python interpreter discovery

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.4: unexpected output from Python interpreter discovery

[WARNING]: sftp transfer mechanism failed on [10.1.1.2]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: sftp transfer mechanism failed on [10.1.1.3]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: sftp transfer mechanism failed on [10.1.1.4]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.2]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.3]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.4]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: Platform unknown on host 10.1.1.2 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See

https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.

ok: [10.1.1.2]

[WARNING]: Platform unknown on host 10.1.1.3 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See

https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.

ok: [10.1.1.3]

[WARNING]: Platform unknown on host 10.1.1.4 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See

https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.

ok: [10.1.1.4]

^C [ERROR]: User interrupted execution

[user_a@host_a playbooks]$ ansible all -m command -a 'uptime' -o

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.2: unexpected output from Python interpreter discovery

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.3: unexpected output from Python interpreter discovery

[WARNING]: Unhandled error in Python interpreter discovery for host 10.1.1.4: unexpected output from Python interpreter discovery

[WARNING]: sftp transfer mechanism failed on [10.1.1.2]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: sftp transfer mechanism failed on [10.1.1.3]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: sftp transfer mechanism failed on [10.1.1.4]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.2]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.3]. Use ANSIBLE_DEBUG=1 to see detailed information

[WARNING]: scp transfer mechanism failed on [10.1.1.4]. Use ANSIBLE_DEBUG=1 to see detailed information

10.1.1.2 | CHANGED | rc=0 | (stdout) 09:17:23 up 1 day, 18:20, 4 users, load average: 0.09, 0.03, 0.05

10.1.1.3 | CHANGED | rc=0 | (stdout) 09:17:23 up 51 days, 19:26, 2 users, load average: 0.01, 0.03, 0.05

10.1.1.4 | CHANGED | rc=0 | (stdout) 09:17:23 up 49 days, 22:21, 2 users, load average: 0.00, 0.01, 0.05

^C [ERROR]: User interrupted execution

[user_a@host_a playbooks]$

EDIT: Wanted to add this. There is nothing odd in /var/log/secure and /var/log/messages either when running these ad-hoc commands.

I have setup logging to /var/log/ansible.log, but basically the output from the ad-hoc commands end up in that log, so nothing to report.

EDIT 2: The ad-hoc commands timed out after 10 minutes. It shows unreachable

Failed to connect to the host via ssh: mux_client_request_session: session request failed: Session open refused by peer

ControlSocket /home/user_a/.ansible/cp/ceeab067b3 already exist, disabling multiplexing

Connection to 10.1.1.5 closed by remote host.

Понравилась статья? Поделить с друзьями:
  • Ansible shell ignore error
  • Ansible error reading ssh protocol banner
  • Ann error has occurred please try again later
  • Aniboom error player что делать
  • Angular обработка ошибок