Feat: set fact for user creation

This commit is contained in:
Bertrand Benjamin 2022-01-19 05:55:34 +01:00
parent 200412cfd0
commit af2903ab74

View File

@ -1,12 +1,16 @@
--- ---
# tasks file for user # tasks file for user
- name: set facts
set_fact:
username: "{{ user.username }}"
# Create user # Create user
- name: users -- Ensure wheel group exists - name: users -- Ensure wheel group exists
group: group:
name: wheel name: wheel
state: present state: present
- name: create users - name: "{{ username }}: create user "
ansible.builtin.user: ansible.builtin.user:
name: "{{ user.username }}" name: "{{ user.username }}"
update_password: on_create update_password: on_create
@ -19,7 +23,7 @@
create_home: true create_home: true
# #
- name: ssh -- Add public key - name: "{{ username }}: Add public key"
authorized_key: authorized_key:
user: "{{ user.username }}" user: "{{ user.username }}"
key: "{{ lookup('file', item.keyfile) }}" key: "{{ lookup('file', item.keyfile) }}"
@ -29,10 +33,10 @@
when: false when: false
# Dotfiles # Dotfiles
- name: set dotfiles - name: "{{ username }}: set dotfiles"
import_tasks: dotfiles.yml import_tasks: dotfiles.yml
- name: gtk_settings - name: "{{ username }}: gtk_settings"
dconf: dconf:
key: "{{ item.key }}" key: "{{ item.key }}"
value: "{{ item.value }}" value: "{{ item.value }}"
@ -42,7 +46,7 @@
become_user: "{{ user.username }}" become_user: "{{ user.username }}"
- name: user owns its create_home - name: "{{ username }}: user owns its create_home"
file: file:
path: "/home/{{ user.username }}/.dotfiles" path: "/home/{{ user.username }}/.dotfiles"
owner: "{{ user.username }}" owner: "{{ user.username }}"