feat: support btrfs subvolume for unix user's home dir
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Markus Pesch 2023-11-21 19:37:31 +01:00
parent 728c0484ad
commit e24515d232
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 23 additions and 0 deletions

View File

@ -23,6 +23,7 @@ unix_users: {}
# private_keys:
# - alice@alice-pc.ed25519.key
# home: /home/alice
# btrfs: false
# shell: /bin/bash
# group: alice
# groups: []

View File

@ -4,6 +4,11 @@
ansible.builtin.set_fact:
user_user_home: "{{ unix_user.value.home | default('/home/' + unix_user.key) }}"
- name: "Create btrfs volume for unix user: {{ unix_user.key }}"
community.general.btrfs_subvolume:
name: "{{ user_user_home }}"
when: unix_user.value.btrfs
- name: "Create unix user without additional groups and uid: {{ unix_user.key }}"
ansible.builtin.user:
name: "{{ unix_user.key }}"
@ -56,6 +61,23 @@
state: present
when: unix_user.value.groups is defined and unix_user.value.uid is not defined
- name: "Adapt permissions and copy skel for unix user: {{ unix_user.key }}"
block:
- name: "Copy skel dir"
ansible.builtin.copy:
src: /etc/skel/
dest: "{{ user_user_home }}"
remote_src: true
owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}"
- name: "Change permission unix users home dir: {{ unix_user.key }}"
ansible.builtin.file:
path: "{{ user_user_home }}"
owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}"
state: directory
when: unix_user.value.btrfs
- name: "Create .ssh directory for unix user: {{ unix_user.key }}"
ansible.builtin.file:
path: "{{ user_user_home }}/.ssh"