awx icon indicating copy to clipboard operation
awx copied to clipboard

Playbooks fail with host_key_checking

Open mkempster22 opened this issue 9 years ago • 5 comments

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • UI
SUMMARY

Running a template to execute a playbook fails with ssh unreachable because of strict key checking, I have set host_key_checking = False in ansible.cfg on both containers On a standard Ansible installation not having to use an assortment of containers this option works as it is designed.

ENVIRONMENT
  • AWX version: Unsure, Cloned as of last week
  • AWX install method: Playbook with docker
  • Ansible version: 2.3.2
  • Operating System: RHEL6.9
  • Web Browser: Chrome
STEPS TO REPRODUCE

Standard installation, happens when running any playbook, as the containers have never connected to the hosts (host_key_checking disables the initial part of ssh'ing to a new box where it asks a yes/no question about adding to known_hosts file)

EXPECTED RESULTS

When using host_key_checking = False in the ansible.cfg file used it should skip the strict key checking, I've added it to both containers as it seems a bit vague as to which container is doing the actual connections

ACTUAL RESULTS

Playbook fails with SSH Unreachable

ADDITIONAL INFORMATION

http://docs.ansible.com/ansible/latest/intro_getting_started.html#host-key-checking

mkempster22 avatar Oct 10 '17 07:10 mkempster22

In addition, when I run the playbook you can see that is including the StrictHostKeyChecking=no in the run:

<_[HOSTNAME]_> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o **StrictHostKeyChecking=no** -o

mkempster22 avatar Oct 10 '17 10:10 mkempster22

We already disable host key checking when connecting to the remote system (we've done that for a long time). You said ssh is unreachable... which is not the error I would expect to see if host key checking weren't disabled (or even if your credentials were wrong). I'd expect to see unreachable if it can't connect to the system.

Can you provide some more details like logs from the the run?

matburt avatar Oct 10 '17 11:10 matburt

It fails and displays the standard message we use when connecting to a new server, i've had it do this with standard ansible cli and using the host key checking no has solved this in every case, unfortunately its not very readable in this box but here is the output

TASK [Gathering Facts] *********************************************************12:45:30 27 Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py 28 <_HOSTNAME_> ESTABLISH SSH CONNECTION FOR USER: root 29 <_HOSTNAME_> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/tmp/awx_73_Cj8NIu/cp/%h%p%r '/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' 30 <_HOSTNAME_> (255, '', '|---------------------------------------------------------------|\n| Unauthorised access to, or use of, this system is strictly |\n| prohibited and may lead to prosecution and/or disciplinary |\n| action. |\n| |\n| Disconnect NOW if you have not been expressly authorised to |\n| use this system. |\n| |\n| By accessing this system you consent to the organisation |\n| monitoring and recording any activity or communication on, |\n| or through, the system and retrieving any information |\n| stored within the system. |\n|---------------------------------------------------------------|\n\n=================================================================\nHOSTNAME: _HOSTNAME_\nOS: … fatal: [_HOSTNAME_]: UNREACHABLE! => { 32 "changed": false, 33 "msg": "Failed to connect to the host via ssh: |---------------------------------------------------------------|\n| Unauthorised access to, or use of, this system is strictly |\n| prohibited and may lead to prosecution and/or disciplinary |\n| action. |\n| |\n| Disconnect NOW if you have not been expressly authorised to |\n| use this system. |\n| |\n| By accessing this system you consent to the organisation |\n| monitoring and recording any activity or communication on, |\n| or through, the system and retrieving any information |\n| stored within the system. |\n|---------------------------------------------------------------… 36 37 PLAY RECAP *********************************************************************12:45:31 38 _HOSTNAME_ : ok=0 changed=0 unreachable=1 failed=0

mkempster22 avatar Oct 10 '17 12:10 mkempster22

Normally you'd see a message out of ansible (and tower) if it got stuck waiting for you to accept the hostkey

$ ansible -i ahost.net, all -m command -a "uptime"
The authenticity of host 'ahost.net (a.b.c.d)' can't be established.
ECDSA key fingerprint is SHA256:fyZO7TYFaAcNUa7HuUSKrkzI/P+rISmoSS/HlcW8ayI.
Are you sure you want to continue connecting (yes/no)?

I'd say the first thing we should checkis whether your credentials are right (I see you are connecting as root?)

matburt avatar Oct 11 '17 03:10 matburt

After looking into what you've said there it looks like it was unable to add servers to the known_hosts file therefore although as you pointed out although host_key_checking is disabled by default it couldn't access anyway. Setting up an Ansible user for it to connect as solved this issue. This is fine as we were looking into doing this anyway as its not best practice to use root.

Thanks for the help in solving this, our AWX fully works now after solving a few different issues

mkempster22 avatar Oct 11 '17 08:10 mkempster22