# SPDX-License-Identifier: MIT
---
- name: Deconfigure cluster
  hosts: all
  vars:
    ha_cluster_export_configuration: true
    ha_cluster_cluster_present: false

  tasks:
    - name: Run test
      tags:
        - tests::booted
        - tests::verify
      block:
        - name: Skip test in bootc mode
          include_tasks: tasks/skip_if_bootc.yml

        - name: Set up test environment
          include_role:
            name: linux-system-roles.ha_cluster
            tasks_from: test_setup.yml

        - name: Run HA Cluster role
          include_role:
            name: linux-system-roles.ha_cluster
            public: true

        - name: Stat corosync.conf
          stat:
            path: /etc/corosync/corosync.conf
          register: stat_corosync_conf

        - name: Stat cib.xml
          stat:
            path: /var/lib/pacemaker/cib/cib.xml
          register: stat_cib_xml

        - name: Stat fence_xvm.key
          stat:
            path: /etc/cluster/fence_xvm.key
          register: stat_fence_xvm_key

        - name: Check the files do not exist
          assert:
            that:
              - not stat_corosync_conf.stat.exists
              - not stat_cib_xml.stat.exists
              - not stat_fence_xvm_key.stat.exists

        - name: Check exported configuration
          assert:
            that:
              - ha_cluster_facts == expected_configuration
          vars:
            expected_configuration:
              ha_cluster_cluster_present: false
