# Howto read variables from an vaut encrypted file

**URL:** <https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926>\
**Category:** Ansible Project\
**Created:** [March 7, 2018, 9:07pm UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926 "2018-03-07T21:07:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neccross9](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@neccross9](https://forum.ansible.com/u/neccross9)\
**Post date:** [March 7, 2018, 9:07pm UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/1 "2018-03-07T21:07:53Z")

</div>

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:

`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 8, 2018, 12:13am UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/2 "2018-03-08T00:13:09Z")

</div>

Ansilbe reads the 'root\_pass\_sirus' variable fine, the problem is that  
'TesT1234' variable isn't defined anywhere.

---

<div class="post-metadata">

**Author:** ![neccross9](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@neccross9](https://forum.ansible.com/u/neccross9)\
**Post date:** [March 8, 2018, 6:06am UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/3 "2018-03-08T06:06:06Z")

</div>

Hi Brian,

of course not. it’s supposed to be the value of ‘root\_pass\_sirus’ …

---

<div class="post-metadata">

**Author:** ![Michael-John\_Turner](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@Michael-John\_Turner](https://forum.ansible.com/u/Michael-John_Turner)\
**Post date:** [March 8, 2018, 8:18am UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/4 "2018-03-08T08:18:41Z")

</div>

Brian provided a clue in his answer, but to make it more explicit: root\_pass\_sirius is not correctly declared.

Instead of:  
root\_pass\_sirius: "{{ TesT1234 }}"  
it should be:  
root\_pass\_sirius: "TesT1234"

You want the password to have the value "TesT1234" - in the incorrect declaration, it's being set to the value of a variable called TesT1234, which doesn't exist. Remove the {{ }} and it'll work.

Cheers, MJ

---

<div class="post-metadata">

**Author:** ![Richard\_Sobey](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@Richard\_Sobey](https://forum.ansible.com/u/Richard_Sobey)\
**Post date:** [March 8, 2018, 11:30am UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/5 "2018-03-08T11:30:53Z")

</div>

My limited understanding is that this:

root\_pass\_sirius: “{{ TesT1234 }}”

…is definting another variable called “TesT1234” rather than assigning the literal “TesT1234” to the variable “root\_pass\_sirius” like:

root\_pass\_sirius: “TesT1234”

---

<div class="post-metadata">

**Author:** ![neccross9](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@neccross9](https://forum.ansible.com/u/neccross9)\
**Post date:** [March 8, 2018, 10:13pm UTC](https://forum.ansible.com/t/howto-read-variables-from-an-vaut-encrypted-file/26926/6 "2018-03-08T22:13:08Z")

</div>

unbeliveable … but that was it !!  
Thanks a lot 🙂
