Ansible_workstation/roles/user/tasks/main.yml

52 lines
1.3 KiB
YAML
Raw Permalink Normal View History

---
# tasks file for user
2022-01-19 04:55:34 +00:00
- name: set facts
set_fact:
username: "{{ user.username }}"
2022-01-11 21:20:52 +00:00
# Create user
2022-03-04 04:56:37 +00:00
- name: Ensure wheel group exists
group:
2022-05-18 09:22:18 +00:00
name: "{{ item }}"
state: present
2022-05-18 09:22:18 +00:00
with_items: "{{ user.groups | replace(' ', '') | split(',') }}"
2022-03-04 04:56:37 +00:00
- name: "{{ username }} -- create user "
ansible.builtin.user:
name: "{{ user.username }}"
update_password: on_create
password: "{{ user.password | password_hash('sha512')}}"
group: "{{ user.group | default('users') }}"
groups: "{{ user.groups | default('') }}"
shell: "{{ user.shell | default('/bin/bash') }}"
state: present
system: "{{ user.system | default('no') }}"
2022-01-12 14:04:28 +00:00
create_home: true
2022-03-04 04:56:37 +00:00
- name: "{{ username }} -- Add public key"
2022-05-18 09:22:18 +00:00
authorized_key:
user: "{{ user.username }}"
2022-01-11 21:20:52 +00:00
key: "{{ lookup('file', item.keyfile) }}"
state: present
2022-03-04 04:56:37 +00:00
with_items: "{{ user.public_key | default([]) }}"
2022-01-11 21:20:52 +00:00
2022-03-04 04:56:37 +00:00
- name: "{{ username }} -- set dotfiles"
2022-01-12 05:06:12 +00:00
import_tasks: dotfiles.yml
2022-01-19 04:55:34 +00:00
- name: "{{ username }}: gtk_settings"
2022-01-13 05:09:02 +00:00
dconf:
key: "{{ item.key }}"
value: "{{ item.value }}"
state: present
2022-03-04 04:56:37 +00:00
with_items: "{{ user.gtk_settings | default([]) }}"
2022-01-13 05:09:02 +00:00
become: true
become_user: "{{ user.username }}"
2022-03-04 04:56:37 +00:00
- name: "{{ username }} -- user owns its create_home"
2022-01-12 14:04:28 +00:00
file:
path: "/home/{{ user.username }}/.dotfiles"
owner: "{{ user.username }}"
group: users