--- # due to Ansible limitations, we cannot loop over a block, so we loop over a distinct tasks file... # @see https://stackoverflow.com/a/58911694 - name: Set ownership on dataset mountpoint block: - name: Get the mountpoint ansible.builtin.command: "zfs get -H -o value mountpoint {{ dataset.name }}" register: mountpoint changed_when: false - name: Set owner of mountpoints ansible.builtin.file: path: "{{ mountpoint.stdout }}" owner: "{{ dataset.user | default(main_user) }}" group: "{{ dataset.group | default(main_user) }}" state: directory recurse: true