According to this page it doesn't seem you have to store the key locally and replace it using an environment variable or an ansible variable
https://docs.ansible.com/ansible/2.6/plugins/connection/ssh.html You can remove the key file after the playbook is finished There is another option where you don't have to temporarily store the credential on disk which is using the paramikio_ssh connection. The documentation is located at https://docs.ansible.com/ansible/2.6/plugins/connection/paramiko_ssh.html Tony Chia On Wednesday, August 15, 2018 at 7:35:15 AM UTC-7, Bruce Affonso wrote: > > Hi, > > We are storing private keys in a DB and when we need to run a playbook > would like to pass these SSH keys as an argument instead of storing as a > file locally. > > I tried something like this: > > ansible-playbook -i "1.2.3.4," --extra-vars="ansible_user=username > ansible_ssh_private_key_file=$KEY" playbooks/playbook.yml > > but get message 'No such file or directory' > > It works if I specify a key file (and location). $KEY in an environment > variable with private key contents. > > So, is there a way to pass $KEY without having to create a file? > > Thank you > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/97731586-f100-4cb1-9e30-0f4aaef73b31%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.