ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.02k stars 3.42k forks source link

known_hosts module on ~/.ssh/known_hosts fails inside EE with "No such file or directory" #10984

Open azrdev opened 3 years ago

azrdev commented 3 years ago

Please confirm the following

Summary

Invoking the builtin known_hosts module without a path argument defaults to ~/.ssh/known_hosts, which fails inside an EE.

AWX version

19.2.0

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Running the following task ...

- known_hosts:
   name: example.com
   key: "example.com ssh-rsa ..."
   state: present

through AWX19, i.e. inside an EE, fails with msg:

Failed to write to file /home/ansible/.ssh/known_hosts: [Errno 2] No such file or directory: '/home/ansible/.ssh/tmpyflcwiy3'

Expected results

~/.ssh/known_hosts to be updated

Actual results

Above error, Playbook abort.

Additional information

No response

azrdev commented 3 years ago

I can reproduce this by running the container manually:

$ docker run -it quay.io/ansible/awx-ee  /bin/bash
...
bash-4.4$ ansible localhost -m known_hosts -a 'name=example.com key="example.com ssh-rsa AAAAGIBBER" state=present'
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development.
This is a rapidly changing source of code and can become unstable at any point.
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | FAILED! => {
    "changed": false,
    "msg": "Failed to write to file /home/runner/.ssh/known_hosts: [Errno 2] No such file or directory: '/home/runner/.ssh/tmpazpezdx9'"
}

Seems to be a bug of the known_hosts module, actually

chrismeyersfsu commented 3 years ago

I think the action item here is to pre-create the /home/runner/.ssh directory in the container so that known_hosts file creation does not fail.

azrdev commented 1 year ago

still an issue with quay.io/ansible/awx-ee:latest Image ID cee536461204