reading through vault docs, appears that it’s designed to store variable contents. maybe this should be obvious to me but it isn’t - so maybe someone can point me in the right direction. recommendation for the best way to store a file in vault?
my particular use case is an SSH private key file (password-less, used to enable jumping between servers in a cluster). normally i’d stick this in the files folder and use the copy module to push it.
we do use agent port forwarding for administrators. however there is a separate requirement for each cluster to have it’s own passwordless private key that is used for some other tasks within the cluster.
my particular use case is an SSH private key file (password-less, used to
enable jumping between servers in a cluster). normally i'd stick this in
the files folder and use the copy module to push it.
A bit convoluted maybe, but base64-encode the file, and add it to a YAML
vars file which is then put into ansible-vault?
$ echo "myfile: $(openssl enc -a -A -in filename)" > vars.yml
myfile: aGVsbG8Kd29ybGQKaGVsbG8Kd29ybGQKaGVsbG8Kd29ybGQKaGVsbG8Kd29ybGQKaGVsbG8Kd29ybGQK
i believe that openssh private key files are already text encoded; it looks this way on my servers. this approach had occurred to me also - but can I write a simple, elegant task to get this variable into the file on the hosts? that’s the part that wasn’t obvious to me.
i believe that openssh private key files are already text encoded; it looks
this way on my servers. this approach had occurred to me also - but can I
write a simple, elegant task to get this variable into the file on the
hosts? that's the part that wasn't obvious to me.
They are text-encoded, but not as a single line, which my version does;
it looks better to me in a vars file, though you may be able to
shoehorn multiline strings into YAML.
As for extraction, maybe the following could work (untested!) It
decodes the base64-encoded string (-d) and writes it to the specified
destination.
Is there a reason why the file modules shouldn’t be modified to decrypt data with the vault password?
Jeremy, I don’t see an elegant way to do what you want right now. I’ve resorted to importing a key file as an encrypted configuration variable and then using the ‘echo’ command to write it out until there is a better way.
I’d like to take this back, ssh agent forwarding does work. I have discovered that it only fails when used by the git module. Running commands which use ssh from Ansible does work.