---
### tags:
###   update_config

- name: "Get enabled Prometheus services"
  set_fact:
    prometheus_services_enabled: "{{ prometheus_services_enabled | default([]) + [item] | flatten }}"
  loop_control:
    extended: yes
  loop:
    - "{{ ['alertmanager'] if prometheus_alertmanager_enabled|bool else omit }}"
    - "{{ ['grafana'] if prometheus_grafana_enabled|bool else omit }}"
    - "{{ ['prom2teams'] if prometheus_prom2teams_enabled|bool else omit }}"
    - "{{ ['prometheus'] if prometheus_enabled|bool else omit }}"
  tags:
    - update_config

- name: "Deploy Prometheus service templates for {{ inventory_hostname }}"
  include_role:
    name: hetzner-ansible-sma-deploy
    tasks_from: templates
  vars:
    current_config: "prometheus/{{ service }}_config"
    current_base_path: "{{ service_base_path }}"
    current_destination: "{{ inventory_hostname }}"
    current_owner: "{{ docker_owner }}"
    current_group: "{{ docker_group }}"
  loop: "{{ prometheus_services_enabled }}"
  loop_control:
    loop_var: service
  tags:
    - update_config
