最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ansible playbook uses group_vars default values instead of the ones defined in the vault - Stack Overflow

programmeradmin4浏览0评论

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?

Share Improve this question asked Jan 20 at 9:16 khtehkhteh 3,87010 gold badges58 silver badges103 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Resolved. group_vars/local/.local_vault.yml is the culprit. Must NOT use a hidden file started with a ..

发布评论

评论列表(0)

  1. 暂无评论