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:
|
2020-07-21 01:42:50 +00:00
|
|
|
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
|
|
|
|
2020-07-18 05:58:57 +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"
|
2020-07-18 05:58:57 +00:00
|
|
|
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
|
2020-09-12 03:16:02 +00:00
|
|
|
traefik.http.routers.prometheus.middlewares: "securehttps@file,localonly"
|
|
|
|
traefik.http.routers.prometheus.tls.certresolver: letsencrypt
|
|
|
|
traefik.http.middlewares.localonly.ipwhitelist.sourcerange: "{{ traefik_localonly }}"
|
2020-07-18 05:58:57 +00:00
|
|
|
traefik.docker.network: traefik
|
|
|
|
traefik.enable: "true"
|
2020-04-01 01:47:26 +00:00
|
|
|
|
|
|
|
- name: Start Grafana container
|
|
|
|
docker_container:
|
2020-07-21 01:42:50 +00:00
|
|
|
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"
|
2020-07-18 05:58:57 +00:00
|
|
|
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
|
2020-09-04 06:14:12 +00:00
|
|
|
traefik.http.routers.grafana.tls.certresolver: letsencrypt
|
|
|
|
traefik.http.routers.grafana.middlewares: "securehttps@file"
|
2020-07-18 05:58:57 +00:00
|
|
|
traefik.docker.network: traefik
|
|
|
|
traefik.enable: "true"
|