Hello!
I find some issue and cant resolve it by myself.
My scenario:
3 users, 4 hosts
I add information about users in file vars/all (like login, uid, comment, group and password) and deploy users via role with variable (user logins) into all hosts
==========================hosts file=============
[group1]
serv1
[group2]
serv2
serv3
==================playbook=================
-
hosts: all
vars:
ssh_users: -
“{{user1}}”
roles: -
users_add
-
hosts: group1
vars:
ssh_users: -
“{{user2}}”
-
“{{user3}}”
roles: -
users_add
-
hosts: group2
vars:
ssh_users: -
“{{user2}}”
roles: -
users_add
============= vars/all====================
user1:
- { user: ‘user1’, uid: ‘11111’ }
user2: - { user: ‘user2’, uid: ‘11112’ }
user3: - { user: ‘user3’, uid: ‘11113’ }
============= role file ===================== - name: Add ssh user
user: name={{ item.user }} uid= {{ item.uid}}
with_items: “ssh_users”