Persist Prometheus data in bind mount

This commit is contained in:
Kris Lamoureux 2020-07-30 01:10:27 -04:00
parent fa4aae4dfd
commit 46f2b6c0f6
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
3 changed files with 14 additions and 6 deletions

View File

@ -35,4 +35,4 @@ prom_version: latest
prom_domain: prom.vm.krislamo.org prom_domain: prom.vm.krislamo.org
grafana_version: latest grafana_version: latest
grafana_domain: grafana.vm.krislamo.org grafana_domain: grafana.vm.krislamo.org
prom_targets: "['127.0.0.1', '127.0.0.1:9100']" prom_targets: "['10.0.2.15:9100']"

View File

@ -1,3 +1,3 @@
prom_name: prometheus prom_name: prometheus
grafana_name: grafana grafana_name: grafana
prom_root: "/opt/{{ prom_name }}/config" prom_root: "/opt/{{ prom_name }}"

View File

@ -8,15 +8,21 @@
name: prometheus-node-exporter name: prometheus-node-exporter
state: started state: started
- name: Create Prometheus directories - name: Create Prometheus data directory
file: file:
path: "{{ prom_root }}" path: "{{ prom_root }}/prometheus"
state: directory
owner: nobody
- name: Create Prometheus config directory
file:
path: "{{ prom_root }}/config"
state: directory state: directory
- name: Install Prometheus configuration - name: Install Prometheus configuration
template: template:
src: prometheus.yml.j2 src: prometheus.yml.j2
dest: "{{ prom_root }}/prometheus.yml" dest: "{{ prom_root }}/config/prometheus.yml"
- name: Create Prometheus network - name: Create Prometheus network
docker_network: docker_network:
@ -28,7 +34,9 @@
image: prom/prometheus:{{ prom_version }} image: prom/prometheus:{{ prom_version }}
state: started state: started
restart_policy: always restart_policy: always
volumes: "{{ prom_root }}:/etc/prometheus" volumes:
- "{{ prom_root }}/config:/etc/prometheus"
- "{{ prom_root }}/prometheus:/prometheus"
networks_cli_compatible: true networks_cli_compatible: true
networks: networks:
- name: "{{ prom_name }}" - name: "{{ prom_name }}"