Need guidance with multi-level role variables

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

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

This is what I was looking for! Thanks!

  • Will