# ---
# - name: Create subvolumes on {{ fs.path }}
#   block:
#     - name: Create subvolume {{ fs.path }}{{ subvol.name }}
#       block:
#         - name: "Ensure parent directory exists"
#           ansible.builtin.file:
#             path: "{{ (fs.path + subvol.name) | dirname }}"
#             state: directory

#         - name: "Ensure subvolume exists"
#           community.general.btrfs_subvolume:
#             filesystem_device: "{{ fs.device | default(omit) }}"
#             filesystem_label: "{{ fs.label | default(omit) }}"
#             filesystem_uuid: "{{ fs.uuid | default(omit) }}"

#             name: "{{ subvol.name }}"
#             state: "present"
      
#       loop: "{{ fs.subvolumes }}"
#       loop_var: "subvol"
#   loop: "{{ filesystems }}"
#   loop_var: "fs"

- name: Ensure all BTRFS subvolumes are created
  community.general.btrfs_subvolume:
    filesystem_device: "{{ item.filesystem_device | default(omit) }}"
    filesystem_label: "{{ item.filesystem_label | default(omit) }}"
    filesystem_uuid: "{{ item.filesystem_uuid | default(omit) }}"
    name: "{{ item.name }}"
    recursive: true
  loop: "{{ subvolumes }}"

