homelab/roles/monitoring/tasks/prometheus.yml

34 lines
849 B
YAML
Raw Normal View History

2024-10-15 21:56:15 +05:00
---
- name: Create prometheus docker volume
become: true
community.docker.docker_volume:
name: prometheus
- name: Create prometheus config dir
become: true
ansible.builtin.file:
path: /etc/prometheus
state: directory
mode: "1755"
owner: root
group: root
- name: Copy prometheus config
become: true
ansible.builtin.template:
src: prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
mode: "0644"
owner: root
group: root
register: prometheus_cfg
- name: Create prometheus container
become: true
community.docker.docker_container:
name: prometheus
image: prom/prometheus:v2.54.1
networks:
- name: monitoring
volumes:
- prometheus:/prometheus
- /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
recreate: "{{ prometheus_cfg.changed }}"