# SPDX-License-Identifier: MIT
---
- name: Ensure that the spark role runs
  hosts: all

  roles:
    - role: performancecopilot.metrics.keyserver
    - role: performancecopilot.metrics.pcp
      vars:
        pcp_rest_api: true
        pcp_pmproxy_localonly: 1
    - role: performancecopilot.metrics.spark
      vars:
        spark_export_metrics: true

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

  tasks:
    - name: Check if spark role setup works
      include_tasks: "{{ item }}"
      loop:
        - check_pcp2spark.yml
        - check_pmdaopenmetrics.yml

    - name: Check headers for ansible_managed, fingerprint
      include_tasks: check_header.yml
      vars:
        __fingerprint: "performancecopilot:ansible-pcp"
        __file: "{{ __spark_service_path }}/pcp2spark.service"

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