Ansible_workstation/roles/user/tasks/main.yml

50 lines
1.2 KiB
YAML
Raw Normal View History

---
# tasks file for user
2022-01-11 21:20:52 +00:00
# Create user
- name: users -- Ensure wheel group exists
group:
name: wheel
state: present
- name: create users
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-01-11 21:20:52 +00:00
#
- name: ssh -- Add public key
authorized_key:
user: "{{ user.username }}"
key: "{{ lookup('file', item.keyfile) }}"
state: present
with_items: "{{ user.public_key }}"
2022-01-12 14:04:28 +00:00
#when: user.public_key
when: false
2022-01-11 21:20:52 +00:00
# Dotfiles
2022-01-12 05:06:12 +00:00
- name: set dotfiles
import_tasks: dotfiles.yml
2022-01-13 05:09:02 +00:00
- name: gtk_settings
dconf:
key: "{{ item.key }}"
value: "{{ item.value }}"
state: present
with_items: "{{ user.gtk_settings | default('') }}"
become: true
become_user: "{{ user.username }}"
2022-01-12 14:04:28 +00:00
- name: user owns its create_home
file:
path: "/home/{{ user.username }}/.dotfiles"
owner: "{{ user.username }}"
group: users