# SPDX-License-Identifier: MIT
---
- name: Install custom packages
  hosts: all
  vars_files: vars/main.yml
  vars:
    ha_cluster_cluster_present: false
    __test_extra_package: pcs-snmp
    ha_cluster_extra_packages:
      - "{{ __test_extra_package }}"

  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: Skip test on ostree systems
          meta: end_host
          when: __ha_cluster_is_ostree | d(false)

        - name: Ensure extra package is not installed
          package:
            name: "{{ __test_extra_package }}"
            state: absent

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

        - name: Get packages status
          package_facts:

        - name: Check installed packages
          assert:
            that:
              - __test_extra_package in ansible_facts.packages
