---
  - block:
    - set_fact:
        volume_group: lvm

    - name: Load LVM Configuration
      include_vars:
        file: "c{{ zoox_compute_version }}_{{ zoox_machine_role }}.yml"

    - name: "Create logical voumes"
      lvol:
        vg: "{{ volume_group }}"
        lv: "{{ item.name }}"
        size: "{{ item.size }}"
        resizefs: "{{ 'yes' if item.fstype == 'ext4' else 'no' }}"
        shrink: no
      with_items: "{{ lvm_logical_volumes }}"

    - name: "Create LVM filesystem"
      filesystem:
        fstype: "{{ item.fstype }}"
        dev: "/dev/{{ volume_group }}/{{ item.name }}"
        opts: "-L {{ item.name }}"
        resizefs: "{{ 'yes' if item.fstype == 'ext4' else 'no' }}"
      with_items: "{{ lvm_logical_volumes }}"

    - name: Mount volumes according to /etc/fstab
      command: "mount -a"
      args:
        warn: false

    # Because these directories have a lot of files, using recursive 'chown' because the
    # ansible 'file' module would use python to recursively traverse it.
    - name: Ensure correct ownership for LVM partitions
      command: "chown -R {{ item.owner }}:{{ item.group }} {{ item.mount_point }}"
      with_items: "{{ chown_mount_points }}"
      args:
        warn: no

    become: yes
    when: efi_version == '1'
