HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

What is Ansible's config equivalent of `--vault-password-file`?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
fileequivalentwhatvaultpasswordconfigansible

Problem

According the help of ansible-playbook one could use --user=REMOTE_USER to define the ssh user, but one could also define ansible_ssh_user: REMOTE_USER in either the host- or group_vars.

Question

What variable need to be defined in either the group- or host_vars directory to prevent that --vault-password-file has to be defined while running ansible-playbook?

Attempts

-
When ansible_vault_password_file: ~/.vault_pass.txt is defined in the config the decryption fails:

ERROR! Decryption failed on /path/to/vault


-
No associated vault variables was found in this documentation

Solution

Here is the definition:

DEFAULT_VAULT_PASSWORD_FILE = get_config(p, DEFAULTS, 'vault_password_file', \
'ANSIBLE_VAULT_PASSWORD_FILE', None, value_type='path')


This means that you either put in ansible.cfg or playbook:

vault_password_file: ~/.vault_pass.txt


Or in your shell defined this variable:

export ANSIBLE_VAULT_PASSWORD_FILE=~/.vault_pass.txt

Code Snippets

DEFAULT_VAULT_PASSWORD_FILE = get_config(p, DEFAULTS, 'vault_password_file', \
'ANSIBLE_VAULT_PASSWORD_FILE', None, value_type='path')
vault_password_file: ~/.vault_pass.txt
export ANSIBLE_VAULT_PASSWORD_FILE=~/.vault_pass.txt

Context

StackExchange DevOps Q#703, answer score: 15

Revisions (0)

No revisions yet.