How to include a variable vault in inventory.ini or ansible.cfg

halloleo
Thu, 05 Dec 2024 06:31:54 +0000
Get Help

I have a vault file in vault/secrets.enc with some credential definitions.

When I add the file on the command line like this:

ansible-playbook myplay.yml -e '@vault/secrets.enc' --ask-vault-pass

it works perfectly.

But how can I include this encrypted variables file in inventory.ini or ansible.cfg, so that I don’t need to add it on each CLI invocation? I tried setting vars_files, but could not make it work.

Note: I would like to avoid changing my play files for this, because they should work even with a plain -K invocation as well.

Thanks for any pointers!

8 posts - 4 participants