Best way to provide vault password in CI

65 views
Skip to first unread message

Luke Schlather

unread,
Sep 15, 2020, 5:45:41 PM9/15/20
to Ansible Development
I'm trying to figure out what the best way to provide a vault password for a CI process is. My organization uses Azure Devops, where it is standard to create a secret environment variable, and make that available to the agent which runs my Ansible playbooks. This is also common to other CI systems I have used such as Gitlab, Bamboo, Jenkins, and Github Actions.

I found this issue in which someone claimed that it was insecure to store secrets in environment variables and used that as justification for closing the ticket - however in the typical access pattern this makes my CI pipeline less secure, since I still provide the secret as an environment variable - but now Ansible also forces me to write the secret to disk, introducing another set of vulnerabilities to my application (especially since the agent may be running on shared hardware.)

Environment variables seem like the industry-standard mechanism in CI for sharing secrets with an agent process to run things like Ansible playbooks. It's perplexing that Ansible has chosen not to support this. There is a workaround, but it's very frustrating that the workaround actually decreases the security of the system relative to the straightforward solution of Ansible simply expecting a standard environment variable for the password. I'm rather perplexed and frustrated by the decision to close https://github.com/ansible/ansible/issues/45214

Matt Martz

unread,
Sep 15, 2020, 6:04:48 PM9/15/20
to Luke Schlather, Ansible Development

--


You received this message because you are subscribed to the Google Groups "Ansible Development" group.


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/5048eeed-24a6-49ab-aae0-681523a42b27n%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Luke Schlather

unread,
Sep 15, 2020, 6:32:32 PM9/15/20
to Matt Martz, Ansible Development
It's a secure workaround - it is annoying though. And it adds complexity to a very common use case.
--
Luke Schlather
Devops and Deployment Engineer
STRIVR

f.floimai...@gmail.com

unread,
Sep 16, 2020, 10:04:23 AM9/16/20
to Ansible Development

Fully agree with you!

 

It’s a pity that this isn’t supported via environment variable.

Also in the linked issue it is very well argued why the “workaround” is way more unsafe and violates more rules than the environment variable would.

 

FLORIAN FLOIMAIR
Software Development - IMS

Commend International GmbH
Saalachstrasse 51
5020 Salzburg, Austria

commend.com

LG Salzburg / FN 178618z

Luke Schlather

unread,
Sep 17, 2020, 5:46:13 PM9/17/20
to f.floimai...@gmail.com, Ansible Development
Wait, I think the advice in https://github.com/ansible/ansible/issues/45214#issuecomment-502300660 is flat-out wrong. Ansible doesn't evaluate the bash, it just uses the script as the password. That is really dangerous to have that given out as "the way to do it." People will think it's right and end up basically using no password.

There is an obvious workaround that involves writing the password to a temp file, but again, this makes the entire system less secure.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-devel/JO9WikQpEmc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/b2edd6da-29e6-4e85-992d-e11d6f4cc9b0n%40googlegroups.com.

Matt Martz

unread,
Sep 17, 2020, 5:47:50 PM9/17/20
to Luke Schlather, f.floimai...@gmail.com, Ansible Development
You have to make the script executable, otherwise it's just a random file that is read.

If you make it executable, ansible will execute it, and take the password from stdout of the script.

Luke Schlather

unread,
Sep 17, 2020, 5:50:38 PM9/17/20
to Matt Martz, f.floimai...@gmail.com, Ansible Development
This is a really bad interface that IMO shouldn't even be there. It is incredibly easy to misuse and seems really complicated feature which seems to exist for the purpose of not adding a simple and easy-to-use feature.

Luke Schlather

unread,
Sep 17, 2020, 5:52:18 PM9/17/20
to Matt Martz, f.floimai...@gmail.com, Ansible Development
At the least, the overloading of --vault-password-file seems wrong. There should be a separate option --vault-password-script. (Though again, this seems like a very complicated way to avoid adding a simpler feature that would be better and easier to use.)

Rich Megginson

unread,
Sep 17, 2020, 6:26:31 PM9/17/20
to ansibl...@googlegroups.com
On 9/17/20 3:52 PM, 'Luke Schlather' via Ansible Development wrote:
At the least, the overloading of --vault-password-file seems wrong. There should be a separate option --vault-password-script. (Though again, this seems like a very complicated way to avoid adding a simpler feature that would be better and easier to use.)

Well, it is more or less consistent with the way --inventory works.

Luke Schlather

unread,
Sep 17, 2020, 6:31:27 PM9/17/20
to Rich Megginson, Ansible Development
Inventory has a better failure mode though. If you forget to set the executable bit on your inventory plugin, your playbook is almost certain to fail. Even if it succeeds, you will probably notice nothing happened. If you forget to set the executable bit on a vault password plugin, the plugin source code will be used as the password and you will be none the wiser that your vault is basically obfuscated and not meaningfully encrypted at all.

Reply all
Reply to author
Forward
0 new messages