Two vault files with the same password - will it work?

King
Wed, 07 May 2025 14:21:02 +0000
Get Help

Hi!
I would like to use one vault password with two files with encrypted variables. The main variable I need is ansible_password that is used to connect to hosts, and it is different for different users.

I tried the vault ID feature with no luck. I have vault_user1.yml and vault_user2.yml. They were encrypted with the same password and two vault IDs:

user1

user2

When I run the first playbook with this command:

ansible-playbook playbook1.yml -i inventory.yml --user user1 --vault-id user1@/path/to/vault-client.sh

I get the decrypted value of ansible_password from vault_user1.yml.

Then I run the second playbook like this:

ansible-playbook playbook2.yml -i inventory.yml --user user2 --vault-id user2@/path/to/vault-client.sh

and get the decrypted value of ansible_password from vault_user1.yml again. Am I missing something? It looks like the vault-id is not validated.

Is there any simple way to have one variable with two values encrypted with the same password?

10 posts - 4 participants