# After upgrading from 1.1 to 1.2, the user module no longer picks up variables defined in vars\_file if relative path is used

**URL:** <https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [July 5, 2013, 10:59pm UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077 "2013-07-05T22:59:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 5, 2013, 10:59pm UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/1 "2013-07-05T22:59:56Z")

</div>

I upgrade ansible from 1.1 to 1.2 a few days ago (by git clone and then make deb) on my notebook running Ubuntu 11.04 64 bit.

I soon noticed that my existing playbook for adding users no longer sets a user’s password correctly. To test, I took the [ansible-examples/language\_features/user\_commands.yml at master · ansible/ansible-examples · GitHub](https://github.com/ansible/ansible-examples/blob/master/language_features/user_commands.yml) and simplified it into the attached two versions:

1. user\_vars\_files\_cli.yml
2. user\_vars\_files\_explicit.yml  
together with an external user\_passwords.yml residing in a subdirectory vars.

The two files are residing in /home/zperry/Desktop  
The user\_passwords.yml resides in /home/zperry/Desktop/vars

I ran 1. above like so:  
**$ ansible-playbook user\_vars\_files\_cli.yml --extra-vars “hosts=nb1 user=root vars\_files=vars/user\_passwords.yml” -v**

On the target system (nb1, a netbook running SL 6.3), the /etc/shadow has a {{tset\_password}} in it literally ;-(

I ran 2 above like so:  
**$ ansible-playbook user\_vars\_files\_explicit.yml --extra-vars “hosts=nb1 user=root” -v**

This one works OOTB as anticipated. But I don’t like it since it has a hard-coded path for the external vars\_files

My questions:

1. Has the relative path handling changed since 1.2?
2. How can I get the more flexible (and thus IMHO more desirable) 1. to work with relative path as I have been doing?  
Thanks for any hints.

– Zack

> **(attachments)**
>
> [user\_vars\_files\_cli.yml](https://forum.ansible.com/uploads/short-url/ekPTnloejg3PsCq0tkCPbzueSAu.yml) (412 Bytes)  
> [user\_passwords.yml](https://forum.ansible.com/uploads/short-url/yriyWOjgtQ79L5rvIWDeBe9WAX0.yml) (119 Bytes)  
> [user\_vars\_files\_explicit.yml](https://forum.ansible.com/uploads/short-url/dT6iCgjBMlRTzJLR1zDNr2u7ziB.yml) (384 Bytes)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 5, 2013, 11:04pm UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/2 "2013-07-05T23:04:49Z")

</div>

Can you please send YAML you are asking to the list inline rather than as attachments, or use gist to show structure?

This requires us downloading your files and putting them in the right place, and I’m rather tired to do homework 🙂

Thanks for understanding!

–Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 5, 2013, 11:06pm UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/3 "2013-07-05T23:06:02Z")

</div>

Also please be sure to illustrate your problem in your uploaded files by putting in some comments, highlighting what variables work and don’t, and so on.

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 5, 2013, 11:54pm UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/4 "2013-07-05T23:54:13Z")

</div>

Thanks Michael. See below:

(A) **user\_vars\_files\_cli.yml**

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 6, 2013, 2:27am UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/5 "2013-07-06T02:27:08Z")

</div>

Ah, vars\_files is being passed in as a list! Got it, thanks…

Yeah, I didn’t really expect that to be ever done per se, and the code isn’t really going to make list variables expand like magic if they start as strings now, that’s true and was a consequence of trying to get variables back under control (which we did!)

You can definitely do:

vars\_files:

- “{{ some\_variable\_file\_path }}”

Note, I’m favoring the new variable syntax available in 1.2, it’s simpler because it is the same as in templates, and you don’t have to remember any weird rules for deferenceing arrays or hashes or strings with dots in them. Note that if you start a line with “{{” you must quote the line, because YAML likes it that way.

I should also point out one thing new in 1.2 is --extra-vars can be passed in as quoted JSON if you really want to. Not sure if that helps but can be a great way to define structured data.

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 6, 2013, 2:46am UTC](https://forum.ansible.com/t/after-upgrading-from-1-1-to-1-2-the-user-module-no-longer-picks-up-variables-defined-in-vars-file-if-relative-path-is-used/13077/6 "2013-07-06T02:46:59Z")

</div>

Hi Michael,

> Ah, vars\_files is being passed in as a list! Got it, thanks…

Yup! I have been doing so since ansible 0.4 all the way to 1.1. So, when in 1.2 such usage failed me, I was a bit deflated 😉

> Yeah, I didn’t really expect that to be ever done per se, and the code isn’t really going to make list variables expand like magic if they start as strings now, that’s true and was a consequence of trying to get variables back under control (which we did)

I RTFMed after dinner and found this role. It somewhat helps. But it’s also quite strict. For example, per [http://www.ansibleworks.com/docs/playbooks.html#roles](http://www.ansibleworks.com/docs/playbooks.html#roles),  
I mkdir roles/common/vars  
but then ansible-playbook user\_vars\_files\_roles.yml --extra-vars “hosts=nb1 user=root vars\_files=user\_passwords.yml” --list-hosts refused to run until I also created

- roles/common/files/main
- roles/common/tasks/main
- roles/common/handlers/main
- roles/common/library

8-( A lot of extra stuff that I don’t need for now. But at least it works with a mv roles/common/vars/user\_passwords.yml roles/common/vars/main.yml  
as instructed by [http://www.ansibleworks.com/docs/playbooks.html#roles](http://www.ansibleworks.com/docs/playbooks.html#roles)

The following simply test playbook works:
