role_users/tasks/installation.yml

35 lines
992 B
YAML

---
# tasks file for users
- name: Créer un groupe au nom de l'utilisateur
ansible.builtin.group:
name: "{{ item.name }}"
when: user.group is undefined
become: true
loop: "{{ users }}"
loop_control:
label: "{{ item.name }}"
- name: Créer les autres groupes
ansible.builtin.group:
name: "{{ item.1 }}"
become: true
loop: "{{ users | subelements('groups', skip_missing=True) }}"
loop_control:
label: "{{ item.0.name }} to {{ item.1 }}"
- name: Créer les utilisateurs
ansible.builtin.user:
name: "{{ item.name }}"
comment: "{{ item.comment | default(omit) }}"
password: "{{ item.password | default(omit) }}"
password_lock: "{{ item.password_lock | default(omit) }}"
home: "{{ item.home | default(omit) }}"
shell: "{{ item.shell | default(omit) }}"
group: "{{ item.group | default(item.name) }}"
groups: "{{ item.groups | default(omit) }}"
become: true
loop: "{{ users }}"
loop_control:
label: "{{ item.name }}"