# SPDX-License-Identifier: MIT
---
- name: Ensure mandatory variables are defined
  hosts: all
  gather_facts: false
  tasks:
    - name: Run test
      tags: tests::verify
      block:
        - name: Set up test environment
          include_role:
            name: linux-system-roles.ha_cluster
            tasks_from: test_setup.yml

        - name: Run the role
          include_role:
            name: linux-system-roles.ha_cluster
      rescue:
        - name: Extract errors
          set_fact:
            error_list: "{{
              ansible_failed_result.results | map(attribute='msg') |
              list }}"
          run_once: true  # noqa: run_once[task]

        - name: Check errors
          assert:
            that:
              - "'ha_cluster_hacluster_password must be specified'
                  in error_list"
