Hi,
I am trying to create users and groups and add users to groups and keys well, you know.
Does this layout looks correct?
vars/users.yml
groups:
admins:
state: present
webmasters:
state: present
admins:
user1:
state: present
authorized:
- keys/ssh/user1.pub
webmasters:
user2:
state: present
authorized:
- keys/ssh/user2.pub
user3:
state: present
authorized: - keys/ssh/user3.pub
user4:
state: present
authorized: - keys/ssh/user4.pub
tasks/main.yml
-
name: Admins
user:
name={{ item.key }}
shell=/bin/bash
createhome=yes
state={{ item.value.state }}
with_dict: admins -
name: Webmasters
user:
name={{ item.key }}
shell=/home/bash
createhome=yes
state={{ item.value.state }}
with_dict: webmasters -
name: Groups
group: name={{ item.key }} state={{ item.value.state }}
with_dict: groups
I get users admins and webmasters created but when creating groups things went wrong…
“…
TASK: […/roles/support | SUPPORT | add groups] ***************
fatal: [support] => One or more undefined variables: ‘list object’ has no attribute ‘state’
FATAL: all hosts have already failed — aborting
…”
The question is: Is this layout the best approach for managing users/groups and keys?
Cheers,
Frank