---
- name: Test snapshot fails when set has duplicates
  hosts: all
  vars:
    test_disk_min_size: "1g"
    test_disk_count: 10
    test_storage_pools:
      - name: test_vg1
        disks: "{{ range(0, 3) | map('extract', unused_disks) | list }}"
        volumes:
          - name: lv1
            size: "15%"
          - name: lv2
            size: "50%"
      - name: test_vg2
        disks: "{{ range(3, 6) | map('extract', unused_disks) | list }}"
        volumes:
          - name: lv3
            size: "10%"
          - name: lv4
            size: "20%"
      - name: test_vg3
        disks: "{{ range(6, 10) | map('extract', unused_disks) | list }}"
        volumes:
          - name: lv5
            size: "30%"
          - name: lv6
            size: "25%"
          - name: lv7
            size: "10%"
          - name: lv8
            size: "10%"
    snapshot_test_set:
      name: snapset1
      volumes:
        - name: snapshot VG1 LV1
          vg: test_vg1
          lv: lv1
          percent_space_required: 15
          mountpoint_create: false
        - name: snapshot VG1 LV1
          vg: test_vg1
          lv: lv1
          percent_space_required: 15
          mountpoint_create: false
        - name: snapshot VG2 LV3
          vg: test_vg2
          lv: lv3
          percent_space_required: 15
          mountpoint_create: false
        - name: snapshot VG2 LV3
          vg: test_vg2
          lv: lv3
          percent_space_required: 15
          mountpoint_create: false
        - name: snapshot VG2 LV4
          vg: test_vg2
          lv: lv4
          percent_space_required: 15
          mountpoint_create: false
        - name: snapshot VG3 LV7
          vg: test_vg3
          lv: lv7
          percent_space_required: 15
          mountpoint_create: false
  tasks:
    - name: Run tests
      block:
        - name: Setup
          include_tasks: tasks/setup.yml

        - name: Test snapshot verify failure
          include_tasks: verify-role-failed.yml
          vars:
            __snapshot_failed_regex:
              "duplicates in set*"
            __snapshot_failed_msg: Role did not fail with duplicates
            __snapshot_failed_params:
              snapshot_lvm_action: snapshot
              snapshot_lvm_verify_only: true
              __snapshot_lvm_set: "{{ snapshot_test_set }}"
            __snapshot_failed_changed: false
      always:
        - name: Cleanup
          include_tasks: tasks/cleanup.yml
          tags: tests::cleanup
