# Converting a general list of values to specific role-parameters

**URL:** <https://forum.ansible.com/t/converting-a-general-list-of-values-to-specific-role-parameters/19931>\
**Category:** Ansible Project\
**Created:** [December 3, 2015, 6:31pm UTC](https://forum.ansible.com/t/converting-a-general-list-of-values-to-specific-role-parameters/19931 "2015-12-03T18:31:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Lutonsky](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Lutonsky](https://forum.ansible.com/u/Michael_Lutonsky)\
**Post date:** [December 3, 2015, 6:31pm UTC](https://forum.ansible.com/t/converting-a-general-list-of-values-to-specific-role-parameters/19931/1 "2015-12-03T18:31:12Z")

</div>

Hello!

Assume there is a general list of entities (for example: users), which looks like this:

- hosts: 127.0.0.1  
&nbsp;&nbsp;&nbsp;gather\_facts: false  
&nbsp;&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;- users:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: luto  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;realname: Michael Lutonsky  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: sue  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;realname: Susan Smith

Now I've got multiple roles, which I'd like to use:

1. a role which creates unix users; Parameters: a list of users (attributes: name, home, comment, ...)  
2. a role which creates a web presence for each user; Parameters: a list of vhosts (attributes: servername, docroot, ...)

Real-Life examples for this would be: [https://github.com/willshersystems/ansible-users](https://github.com/willshersystems/ansible-users) and [https://github.com/jdauphant/ansible-role-nginx](https://github.com/jdauphant/ansible-role-nginx)

So the array  
&nbsp;&nbsp;&nbsp;[{ name: "luto", realname: "Michael Lutonsky" }, { name: "sue", ... }]  
needs to be converted to  
&nbsp;&nbsp;&nbsp;[{ name: "luto", home: "/home/luto", comment: "Michael Lutonsky" }, ...]  
and  
&nbsp;&nbsp;&nbsp;[{ servername: "luto.company.org", docroot: "/var/www/luto" }, ...].

I've come across the following PR, which has a workaround at the very bottom: [https://github.com/ansible/ansible/pull/8019](https://github.com/ansible/ansible/pull/8019) But this seems rather cumbersome and hacky to me.

So, what is the ansible-way of achieving this?

Regards and Thank You,  
luto
