I have the following structure:
|- group_vars/
|- local/
|- local.yml
|- roles/
|- myrole/
|- vars/
|- main.yml
groups_vars/local/local.yml
:
myvar: <FIXME>
roles/myrole/vars/main.yml
:
myvar: "{{ var_myvar }}"
local_playbook.yml
:
- hosts: local
tasks:
- name: Print variables
ansible.builtin.debug:
msg: "{{ var_myvar }}"
roles:
- myrole
I created an encrypted file for the var_myvar
value:
ansible-vault create --vault-id [email protected] group_vars/local/.local_vault.yml
and verify that it is there in the encrypted file with ansible-vault edit
. However, when the playbook runs it shows the old / default values defined in groups_vars/local/local.yml
instead of using the values defined in the vault. What do I miss?
I have the following structure:
|- group_vars/
|- local/
|- local.yml
|- roles/
|- myrole/
|- vars/
|- main.yml
groups_vars/local/local.yml
:
myvar: <FIXME>
roles/myrole/vars/main.yml
:
myvar: "{{ var_myvar }}"
local_playbook.yml
:
- hosts: local
tasks:
- name: Print variables
ansible.builtin.debug:
msg: "{{ var_myvar }}"
roles:
- myrole
I created an encrypted file for the var_myvar
value:
ansible-vault create --vault-id [email protected] group_vars/local/.local_vault.yml
and verify that it is there in the encrypted file with ansible-vault edit
. However, when the playbook runs it shows the old / default values defined in groups_vars/local/local.yml
instead of using the values defined in the vault. What do I miss?
1 Answer
Reset to default 1Resolved. group_vars/local/.local_vault.yml
is the culprit. Must NOT use a hidden file started with a .
.