Feat: concatenate users and dotfiles into user

This commit is contained in:
2022-01-11 21:58:59 +01:00
parent 0d3d0219a5
commit 9cc854401a
16 changed files with 322 additions and 0 deletions

12
roles/user/tasks/arch.yml Normal file
View File

@@ -0,0 +1,12 @@
---
- name: Install stow
community.general.pacman:
name: stow
state: present
become: true
- name: Install git
community.general.pacman:
name: git
state: present
become: true

View File

@@ -0,0 +1,14 @@
---
- name: Install stow
apt:
name: stow
state: present
update_cache: yes
become: true
- name: Install git
apt:
name: git
state: present
update_cache: yes
become: true

45
roles/user/tasks/main.yml Normal file
View File

@@ -0,0 +1,45 @@
---
# tasks file for 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') }}"
- name: Install for arch
import_tasks: arch.yml
when: ansible_os_family == "Archlinux"
- name: Install for debian
import_tasks: debian.yml
when: ansible_os_family == "Debian"
- name: Clone dotfiles
ansible.builtin.git:
repo: "{{ user.config.giturl }}"
dest: "/home/{{ user.username }}/.dotfiles"
become: yes
- name: user owns its dotfiles
ansible.builtin.file:
path: "/home/{{ user.username }}/.dotfiles"
owner: "{{ user.username }}"
become: yes
- name: stow configs
ansible.builtin.command:
cmd: stow {{ item }}
chdir: "/home/{{ user.username }}/.dotfiles"
with_items: "{{ user.config.stowing }}"
become: yes