linuxinstaller/ansible/ajoute-utilisateur.yml
2024-10-19 19:10:07 +02:00

27 lines
689 B
YAML

- name: Ajoute utilisateur
hosts: localhost
vars:
default_groups:
- cdrom
- dip
- plugdev
- users
- lpadmin
- sambashare
tasks:
- name: Configure un compte pour {{ username }}
ansible.builtin.user:
name: "{{ username }}"
comment: "{{ prenom_nom }}"
groups: "{{ default_groups }}"
append: true
password: "{{ 'achanger' | password_hash('sha512') }}"
update_password: on_create
create_home: true
shell: /bin/bash
register: _user
- name: Expire le mot de passe de {{ username }}
ansible.builtin.command: passwd -e {{ username }}
when: _user.changed