Configuration of /etc/ansible/hosts

Hello,

I would like to define a SSH private key by host in /etc/ansible/hosts of my « awxcontainer_awx_task_1 » docker container.
If I login in this container and try to use the hosts defined in the ansible configuration it works.

But if I use the same playbook in AWX it’s not working. It can’t find the host definition in /etc/ansible/hosts.

Is it a bug or it’s not working like that ?

PS : I know I can defined hosts directly in AWX ;).

AWX will always use the hosts defined in its inventory when running playbooks, and never /etc/ansible/hosts.

You can define those private keys in your inventory if you’re importing inventory from a project, or in host_vars/host.yml files alongside your playbook. I’d highly recommend using vault in both cases; the inventory approach may depend on https://github.com/ansible/awx/issues/223 being implemented, the second should work by providing a vault credential in your job template.