infra/roles/prometheus/tasks/main.yml
2026-01-19 15:02:13 -05:00

30 lines
731 B
YAML

---
- name: Create Prometheus directory
file:
path: /opt/prometheus
state: directory
- name: Ensure monitoring network exists
command: docker network inspect monitoring
register: monitoring_network
changed_when: false
failed_when: false
- name: Create monitoring network if missing
command: docker network create monitoring
when: monitoring_network.rc != 0
- name: Copy Prometheus configuration
template:
src: prometheus.yml.j2
dest: /opt/prometheus/prometheus.yml
- name: Copy Docker Compose file for Prometheus
template:
src: docker-compose.yml.j2
dest: /opt/prometheus/docker-compose.yml
- name: Deploy Prometheus
command: docker compose up -d
args:
chdir: /opt/prometheus