# SPDX-License-Identifier: MIT
---
- name: Test qnetd setup
  hosts: all
  vars_files: vars/main.yml
  vars:
    ha_cluster_cluster_present: false
    ha_cluster_qnetd:
      present: true
    ha_cluster_manage_firewall: true
    ha_cluster_manage_selinux: true
  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: Clean up test environment for qnetd
          include_role:
            name: linux-system-roles.ha_cluster
            tasks_from: test_cleanup_qnetd.yml

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

        - name: Get services status
          service_facts:

        - name: Check services status
          assert:
            that:
              - ansible_facts.services["corosync-qnetd.service"].status
                == "enabled"
              - ansible_facts.services["corosync-qnetd.service"].state
                 == "running"

        - name: Check firewall and selinux state
          include_tasks: tasks/check_firewall_selinux.yml
