Ansible 'wait_for_connection' "Error reading SSH protocol banner" (time out) from Kubernetes pod

6/18/2020

Short background;
I have created a Jenkins master on EC2 and attached a Kubernetes cluster as worker (Amazon EKS).
I have used Kubernetes plugin and created an jnlp slave image that mimics the master's installations, versions and prerequisites.
Everything worked as expected untill I have executed the 'wait_for_connection' module, right after instance creation;

- name: Wait for system to become reachable
  hosts: just_created
  remote_user: "{{ remote_image_user }}"
  gather_facts: false
  become: True
  become_user: root

  vars:
     remote_image_user: "ec2-user"

  tasks:
    - name: Wait for system to become reachable
      wait_for_connection:

The time out error recieved from the worker pod:

fatal: FAILED! => {"changed": false, "elapsed": 600, "msg": "timed out waiting for ping module test success: Error reading SSH protocol banner"}

Additional information:

  1. Connection is performed with public IPs, I do have telnet working to the host IP from the EKS worker node (EC2).
  2. The same exact module works if the master (EC2) is running it.
  3. Both jenkins master & pod have the same Ansible --version:
ansible 2.7.10
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Jun 16 2020, 13:32:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

What do i miss? why ansible struggles to SSH from within the pod to another host?

-- Ron Gimpelevich
jenkins
jnlp
kubernetes
paramiko

1 Answer

6/18/2020

For those who face the same issue, I found the cause for this, some changes to to be made to the ansible.cfg:

host_key_checking = False
record_host_keys=False
-- Ron Gimpelevich
Source: StackOverflow