---
- name: Monitoring Playbook (K8s)
  hosts: monitoring
  gather_facts: true

# Specific tasks for this playbook
  tasks:
    - name: Set required facts
      ansible.builtin.set_fact:
        monitoring_home: "/var/lib/monitoring"
        influxdb_home: "/var/lib/monitoring/influxdb.data"
        kapacitor_home: "/var/lib/monitoring/kapacitor.data"
        cronograf_home: "{{ persistent_data | default('/var/lib') }}/chronograf.data"
        monitoring_user_id: 1000
        monitoring_group_id: 1000
      tags: always

    - name: Create required monitoring data folder
      become: true
      ansible.builtin.file:
        state: directory
        path: "{{ item }}"
        mode: "0750"
        owner: "{{ monitoring_user_id }}"
        group: "{{ monitoring_group_id }}"
      with_items:
        - "{{ monitoring_home }}"
        - "{{ influxdb_home }}"
        - "{{ kapacitor_home }}"
        - "{{ cronograf_home }}"
      tags:
        - tasks
        - tasks::folders
