---
- name: Prometheus
  hosts: monitor.mgmt.toal.ca # Hard-coded for now
  become: yes
  vars:
    container_image: prom/prometheus
    container_name: prometheus
    container_state: running
    container_firewall_ports:
      - 8090/tcp
    container_run_args: >-
      -p 8090:8090
      -v /home/prometheus/etc:/etc/prometheus:Z
      -v /home/prometheus/data:/prometheus:Z
      -v /home/prometheus/console_libraries:/usr/share/prometheus/console_libraries:Z
      -v /home/prometheus/console_templates:/usr/share/prometheus/consoles:Z
  roles:
    - ikke_t.podman_container_systemd

  pre_tasks:
    - name: Directories exist
      file:
        path: '{{ item }}'
        state: directory
        owner: nobody
        group: nobody
      loop:
        - /home/prometheus/etc
        - /home/prometheus/data
        - /home/prometheus/console_libraries
        - /home/prometheus/console_template
  post_tasks:
    - name: Firewall
      firewalld:
          state: enabled # required. choices: enabled;disabled;present;absent. Enable or disable a setting. For ports: Should this port accept(enabled) or reject(disabled) connections. The states "present" and "absent" can only be used in zone level operations (i.e. when no other parameters but zone and state are set).
          permanent: true
          port: 9090/tcp

- name: Grafana
  hosts: monitor.mgmt.toal.ca # Hard-coded for now
  become: yes
  vars:
    container_image: grafana/grafana
    container_name: grafana
    container_state: running
    container_firewall_ports:
      - 3000/tcp
    container_run_args: >-
      -p 3000:3000
      -v /home/grafana/data:/var/lib/grafana:Z
  pre_tasks:
    - name: Directories exist
      file:
        path: '{{ item }}'
        state: directory
        owner: nobody
        group: nobody
      loop:
        - /home/grafana/data
  roles:
    - ikke_t.podman_container_systemd
  post_tasks:
    - name: Firewall
      firewalld:
          state: enabled # required. choices: enabled;disabled;present;absent. Enable or disable a setting. For ports: Should this port accept(enabled) or reject(disabled) connections. The states "present" and "absent" can only be used in zone level operations (i.e. when no other parameters but zone and state are set).
          permanent: true
          port: 3000/tcp
