- Add Prometheus alert rules configuration (alerts.yml.j2) - Update Prometheus docker-compose and main configuration - Add Grafana tasks for improved deployment and verification - Integrate Alertmanager with Prometheus for alerting pipeline
35 lines
840 B
YAML
35 lines
840 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 Prometheus alert rules
|
|
template:
|
|
src: alerts.yml.j2
|
|
dest: /opt/prometheus/alerts.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
|