I want to create a file (namely an id_rsa
key) using ansible
.
It seems that using the copy
builtin module is no longer recommended and users are advised to use template
.
If I understand correcly, I will have to put the contents of the id_rsa
to an id_rsa.j2
and then render it on the target host.
This of course will then have to be encrypted with ansible-vault
.
My question is whether there is a workaround (since I already have a vars
file with secrets) so that I add the contents of the private key to this (already encrypted) file to avoid adding yet another encrypted file just for this purpose.
You wouldn't put any sensitive information in your template, just the variable name, the same way you would have with copy
+ content
.
{{ my_private_key_var }}