I have a predefined ansible variables, and I want to create linux groups from these variables. The below task create only the groups in the first array g1,g2,g3 How can I loop over all lines to create other groups?
The predefined ansible vars:
user_details:
- { name: "user1", groups: 'g1,g2,g3' }
- { name: "user2", groups: 'g4,g5' }
The task as following:
- name: Create Group
group:
name: "{{ item }}"
state: present
loop: "{{ user_details.0.groups.split(',') }}"