# SPDX-License-Identifier: MIT
---
- name: Ensure that the role runs with mandatory parameters populated
  hosts: all,!ad
  gather_facts: false # test that role works in this case
  vars:
  # sample realm that will skip joining realm step
    ad_integration_realm: "{{ __ad_integration_sample_realm }}"
    ad_integration_password: Secret123

  tasks:
    - name: Test - Run the system role
      include_role:
        name: redhat.rhel_system_roles.ad_integration

    - name: Test - Check packages are present
      block:
        - name: Gather package facts
          package_facts:
        - name: Assert that expected packages are installed
          assert:
            that:
              - "'realmd' in ansible_facts.packages"
              - "'PackageKit' in ansible_facts.packages"

    - name: Test - Check that realmd config is present
      stat:
        path: /etc/realmd.conf
      register: __stat_result
      failed_when: not __stat_result.stat.exists
      changed_when: false
