From 91ba7845daf2d5a4f6013ec88c52b5e24f00912c Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Tue, 8 Sep 2026 15:51:14 +0200 Subject: [PATCH] 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 --- tasks/create_unix_user.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tasks/create_unix_user.yaml b/tasks/create_unix_user.yaml index 14354bd..33bfa86 100644 --- a/tasks/create_unix_user.yaml +++ b/tasks/create_unix_user.yaml @@ -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: