35 lines
893 B
YAML
35 lines
893 B
YAML
|
- name: Ajoute utilisateur
|
||
|
hosts: localhost
|
||
|
vars:
|
||
|
default_groups:
|
||
|
- cdrom
|
||
|
- dip
|
||
|
- plugdev
|
||
|
- users
|
||
|
- lpadmin
|
||
|
- sambashare
|
||
|
vars_prompt:
|
||
|
- name: username
|
||
|
prompt: "Identifiant de l'utilisateur concerné"
|
||
|
private: false
|
||
|
- name: prenom_nom
|
||
|
prompt: "Prénom et nom de l'utilisateur"
|
||
|
private: false
|
||
|
|
||
|
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
|