grafana/tasks/prometheus.yaml

72 lines
1.7 KiB
YAML

---
# create directories
- name: "create prometheus directory"
ansible.builtin.file:
path: "/mnt/prometheus"
state: "directory"
owner: "nobody"
group: "nogroup"
mode: "0775"
- name: "create prometheus data directory"
ansible.builtin.file:
path: "/mnt/prometheus/data"
state: "directory"
owner: "nobody"
group: "nogroup"
mode: "0775"
# yamllint disable
# create prometheus config
- name: "create prometheus config"
ansible.builtin.copy:
dest: "/mnt/prometheus/prometheus.yml"
mode: "0644"
content: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'unbound'
static_configs:
- targets: ['dns01.siempie.internal:9167']
- targets: ['dns02.siempie.internal:9167']
notify: "restart prometheus"
# yamllint enable
# run prometheus
- name: "run prometheus"
community.docker.docker_container:
# docker defaults
auto_remove: "no"
container_default_behavior: "no_defaults"
detach: "yes"
init: "no"
interactive: "no"
log_driver: "json-file"
log_options:
max-size: "5m"
max-file: "3"
memory: "0"
paused: "no"
privileged: "no"
pull: "always"
read_only: "no"
state: "started"
tty: "no"
# run prometheus
name: "prometheus"
image: "docker.io/prom/prometheus:v3.7.2"
image_name_mismatch: "recreate"
restart_policy: "unless-stopped"
network_mode: "host"
volumes:
- "/mnt/prometheus/data:/prometheus"
- "/mnt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro"
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"