homelab/roles/prometheus/tasks/main.yml

72 lines
2.1 KiB
YAML
Raw Normal View History

2020-04-01 01:47:26 +00:00
- name: Install Prometheus node exporter
apt:
name: prometheus-node-exporter
state: present
- name: Run Prometheus node exporter
service:
name: prometheus-node-exporter
state: started
2020-07-30 05:10:27 +00:00
- name: Create Prometheus data directory
2020-04-01 01:47:26 +00:00
file:
2020-07-30 05:10:27 +00:00
path: "{{ prom_root }}/prometheus"
state: directory
owner: nobody
- name: Create Prometheus config directory
file:
path: "{{ prom_root }}/config"
2020-04-01 01:47:26 +00:00
state: directory
2020-03-21 06:38:35 +00:00
- name: Install Prometheus configuration
template:
src: prometheus.yml.j2
2020-07-30 05:10:27 +00:00
dest: "{{ prom_root }}/config/prometheus.yml"
2020-03-21 06:38:35 +00:00
- name: Create Prometheus network
docker_network:
name: "{{ prom_name }}"
2020-03-21 00:32:44 +00:00
- name: Start Prometheus container
docker_container:
name: "{{ prom_name }}"
image: prom/prometheus:{{ prom_version }}
2020-03-21 05:35:51 +00:00
state: started
2020-03-21 00:32:44 +00:00
restart_policy: always
2020-07-30 05:10:27 +00:00
volumes:
- "{{ prom_root }}/config:/etc/prometheus"
- "{{ prom_root }}/prometheus:/prometheus"
networks_cli_compatible: true
networks:
- name: "{{ prom_name }}"
- name: traefik
labels:
traefik.http.routers.prometheus.rule: "Host(`{{ prom_domain }}`)"
traefik.http.routers.prometheus.entrypoints: websecure
traefik.http.routers.prometheus.middlewares: "securehttps@file,localonly"
traefik.http.routers.prometheus.tls.certresolver: letsencrypt
traefik.http.middlewares.localonly.ipwhitelist.sourcerange: "{{ traefik_localonly }}"
traefik.docker.network: traefik
traefik.enable: "true"
2020-04-01 01:47:26 +00:00
- name: Start Grafana container
docker_container:
name: "{{ grafana_name }}"
image: grafana/grafana:{{ grafana_version }}
2020-07-29 04:43:31 +00:00
state: started
restart_policy: always
2020-08-10 02:06:41 +00:00
user: root
2020-08-01 03:05:11 +00:00
volumes: "{{ grafana_root }}:/var/lib/grafana"
networks_cli_compatible: true
networks:
- name: "{{ prom_name }}"
- name: traefik
labels:
traefik.http.routers.grafana.rule: "Host(`{{ grafana_domain }}`)"
traefik.http.routers.grafana.entrypoints: websecure
traefik.http.routers.grafana.tls.certresolver: letsencrypt
traefik.http.routers.grafana.middlewares: "securehttps@file"
traefik.docker.network: traefik
traefik.enable: "true"