# Need guidance with multi-level role variables

**URL:** <https://forum.ansible.com/t/need-guidance-with-multi-level-role-variables/16791>\
**Category:** Ansible Project\
**Created:** [November 14, 2014, 5:09pm UTC](https://forum.ansible.com/t/need-guidance-with-multi-level-role-variables/16791 "2014-11-14T17:09:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 14, 2014, 5:09pm UTC](https://forum.ansible.com/t/need-guidance-with-multi-level-role-variables/16791/1 "2014-11-14T17:09:47Z")

</div>

Hi all,

I have some role variables currently that are single-level, for example a list of IT users:

# Members of the IT Dept.

it\_users:

- bill
- fred
- sam

Now, for another role I’m defining, I’ll need to include some data for each user, such as UID, password hash, homedir path, so I can properly set up local accts via the user module. How do I properly define attributes for each user, and then pull them in to the arguments of the user module?

Thanks,  
Will

---

<div class="post-metadata">

**Author:** ![Tore\_Olsen](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tore\_Olsen](https://forum.ansible.com/u/Tore_Olsen)\
**Post date:** [November 17, 2014, 10:31am UTC](https://forum.ansible.com/t/need-guidance-with-multi-level-role-variables/16791/2 "2014-11-17T10:31:22Z")

</div>

Hi Willard,

Keeping information in one place, is there a reason why you cannot change it\_users to be dictionaries?

it\_users:

- { name: bill, uid: 501, passwd: hash, home: /home/bill }
- { name: fred, uid: 501, … }
- { name: sam, … }

Now you can access these items in the user module or elsewhere like this:

- user: name={{ item.name }} home={{ item.home }} password={{ item.passwd }}  
with\_items: it\_staff

Regards,  
-Tore

---

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 17, 2014, 6:56pm UTC](https://forum.ansible.com/t/need-guidance-with-multi-level-role-variables/16791/3 "2014-11-17T18:56:56Z")

</div>

This is what I was looking for! Thanks!

- Will
