Hi all,
the following task may sound easy but actually it fails all the time ...
I want to store my password in a variable and put it into an ansible-vault encrypted file.
The content of this file will look like this:
---
root_pass_sirius: "{{ TesT1234 }}"
Now my check.yml shall read the encrypted file, get the password and login
---
- hosts: sirius
remote_user: ansible
# gather_facts: no
become: yes
become_method: su
vars_files:
- enc_vars.yml
vars:
ansible_become_pass: '{{ root_pass_sirius }}'
But the login fails with:
FAILED! => {
"msg": "The field 'become_pass' has an invalid value, which includes an undefined variable. The error was: {{ Test1234 }}: 'TesT1234' is undefined\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: {{ TesT1234 }}: 'TesT1234' is undefined"
}
So it looks like ansible is unable to get the variable out of the encrypted file ... but WHY ?