Commit 3ff504a9 authored by Mattia Rizzolo's avatar Mattia Rizzolo

common/users: refactor the flow, set the users according to the handled_users variable

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent a57c8812
...@@ -14,39 +14,33 @@ ...@@ -14,39 +14,33 @@
system: "{{ item.system | default('no') }}" system: "{{ item.system | default('no') }}"
with_items: "{{ handled_groups }}" with_items: "{{ handled_groups }}"
- name: Create a group for every user
group: name={{ item.name }}
with_items: "{{ handled_users }}"
when:
- item.group is not defined
- name: create user manager - name: create the users
user: user:
name: manager name: "{{ item.name }}"
groups: allow-ssh,passwordless-sudo comment: "{{ item.gecos }}"
state: present createhome: yes
shell: /bin/bash home: "{{ item.home | default('/home/'+item.name) }}"
shell: "{{ item.shell | default('/bin/bash') }}"
generate_ssh_key: yes
- name: set ssh keys for manager ssh_key_bits: 4096
authorized_key: group: "{{ item.group | default(item.name) }}"
user: manager update_password: on_create
key: "{{ management_ssh }}" with_items: "{{ handled_users }}"
exclusive: true - name: Add the users to the extra groups, if the groups are available
state: present
- name: create admin users
user: user:
name: "{{ item }}" name: "{{ item.0.name }}"
groups: allow-ssh,passwordless-sudo,systemd-journal groups: "{{ item.1 }}"
append: true append: yes
state: present with_subelements:
shell: /bin/bash - "{{ handled_users }}"
- extra_groups
with_items: "{{ admin_users.keys() }}"
- name: register admin users as a fact
set_fact:
facts_common_admin_users: "{{ admin_users.keys() }}"
- name: set ssh keys for admin users - name: set ssh keys for admin users
authorized_key: authorized_key:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment