# SPDX-License-Identifier: MIT
---
- name: Test the full PCP/Redis/Grafana stack
  hosts: all

  roles:
    - role: redhat.rhel_system_roles.metrics
      vars:
        metrics_query_service: true
        metrics_graph_service: true
        metrics_manage_firewall: true
        metrics_manage_selinux: true

  pre_tasks:
    - name: Stop test
      meta: end_host
      when: (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version | int < 8) or ansible_distribution not in ['Fedora', 'RedHat', 'CentOS']

    - name: Save state of services
      import_tasks: get_services_state.yml

  tasks:
    - name: Check if all services work
      include_tasks: "{{ item }}"
      loop:
        - check_pcp.yml
        - check_pmlogger.yml
        - check_pmie.yml
        - check_redis.yml
        - check_pmproxy.yml
        - check_grafana.yml
        - check_grafanapcp.yml
        - check_firewall_selinux.yml

  post_tasks:
    - name: Restore state of services
      import_tasks: restore_services_state.yml
