The AWX-template is prompting for a credential to connect via ssh
to a large list of hosts.
This credential should be used to push
via ssh
to a git-repository, because i don't want to create or share a ssh-key on every host.
This is possible with ansible-playbook
in combination with ssh-agent
.
Is there also a way to use ForwardAgent with AWX?
$ cat ~/.ssh/config
Host *
ForwardAgent yes
$ cat playbook_ssh_forward.yml
---
- name: test ForwardAgent
hosts: all
gather_facts: no
tasks:
- name: check ssh-key
shell: ssh-add -lE md5
register: output
- name: show usable keys
debug:
var: output.stdout
...
$ ansible-playbook -i localhost, playbook_ssh_forward.yml
PLAY [test ForwardAgent] *******************************************************************************************************
TASK [check ssh-key] ***********************************************************************************************************
changed: [localhost]
TASK [show usable keys] ********************************************************************************************************
ok: [localhost] => {
"output.stdout": "2048 MD5:d8:4a:52:41:a7:9e:a3:0d:ff:ff:ff:ff:b5:a3:89:1f rsa-key-20190501 (RSA)"
}
PLAY RECAP *********************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
AWX returns "stderr": "Could not open a connection to your authentication agent."
If possible, I need the ForwardAgent
-Option per AWX-Credential and not changing ansible.cfg
globally:
[ssh_connection]
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=15m -q