fix(tasks): chown the btrfs home directory only after the user exists
The btrfs block chowned the freshly created subvolume to the user right after `btrfs_subvolume`, but the four `ansible.builtin.user` tasks that actually create that user run further below. On a first run the chown therefore aborted with an invalid user error, which made the whole btrfs code path unusable. The task is removed rather than reordered, because an identical chown already exists in the "Adapt permissions and copy skel" block below the user creation. That block also runs the skel copy first, so the file ownership set there is not overwritten afterwards. The subvolume simply stays root owned for a few tasks longer, which a comment now records. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -30,18 +30,12 @@
|
||||
msg: "Determined device {{ _unix_users_btrfs_device.stdout }} does not have a btrfs filesystem"
|
||||
when: _unix_users_device_filesystem != 'btrfs'
|
||||
|
||||
# The subvolume stays root owned until the user exists. It is chowned further below, after the user was created.
|
||||
- name: "Create btrfs volume for unix user: {{ unix_user.key }}"
|
||||
community.general.btrfs_subvolume:
|
||||
filesystem_device: "{{ _unix_users_btrfs_device.stdout }}"
|
||||
name: "{{ user_user_home }}"
|
||||
state: present
|
||||
- name: "Adapt home dir permissions"
|
||||
ansible.builtin.file:
|
||||
path: "{{ user_user_home }}"
|
||||
owner: "{{ unix_user.key }}"
|
||||
group: "{{ unix_user.value.group | default('users') }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: "Create unix user without additional groups and uid: {{ unix_user.key }}"
|
||||
ansible.builtin.user:
|
||||
|
||||
Reference in New Issue
Block a user