Ansible looping over sub-lists
I have a yaml for the creation of a user.
users:
username:
uid: 12345
gid: 6789
secggroups:
- group1
- group3
gecos: user_for_xyz
home: /home/username
I also have a file with just the usernames called users_list. The playbook to create users is as follows:
---
\- name: create users
user: name="{{ item }}" uid={{ users[item]['uid'] }} group={{ users[item][gid] }} comment="{{ users[item]['gecos'] }}" home={{ users[item]['home' }} expires=0
with_items:
\- users_list
How can I loop through the groups to be added to user?