diff --git a/defaults/default.yml b/defaults/default.yml index e758271..64b93ea 100644 --- a/defaults/default.yml +++ b/defaults/default.yml @@ -23,6 +23,7 @@ unix_users: {} # private_keys: # - alice@alice-pc.ed25519.key # home: /home/alice +# btrfs: false # shell: /bin/bash # group: alice # groups: [] diff --git a/tasks/create_unix_user.yml b/tasks/create_unix_user.yml index 49a2569..d0ec5a9 100644 --- a/tasks/create_unix_user.yml +++ b/tasks/create_unix_user.yml @@ -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"