Use SSH Machine credential as ansible_ssh_private_key_file

Is it possible to use an SSH private key stored as a credential as the ansible_ssh_private_key_file value? Im attempting to rotate SSH keys across many and want to store the new SSH keys in AWX and use it on subsequent runs.

ssh machine credentials are passed to the ssh key agent inside of the pod/container. Then when playbook runs, the ssh agent uses that key to connect to your hosts. So in this case, ansible_ssh_private_key_file wouldn’t be set.

For key rotation, you could callback to the awx server (with awx.awx.credential module, or api call) at the end of the playbook run and update that machine credential with a new ssh key.

AWX Team

So is it not possible to call it as a variable like mentioned here? https://access.redhat.com/solutions/3332591

that article is a little dated, and it seems machine username/password isn’t exposed as a variable in your playbook like in that article’s example. Feel free to use that playbook and try it out though

AWX Team