2021-04-29 18:53:56 +02:00
|
|
|
|
---
|
2022-11-14 10:58:21 +01:00
|
|
|
|
- name: 'prometheus | server | assert | check mandatory vars are defined'
|
2021-05-25 18:25:22 +02:00
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "prometheus_server_monitor is defined"
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-05-25 18:25:22 +02:00
|
|
|
|
|
|
|
|
|
- name: 'prometheus | server | create docker network'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
docker_network:
|
2023-01-27 16:51:27 +01:00
|
|
|
|
name: '{{ prometheus_docker_network }}'
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-04-29 18:53:56 +02:00
|
|
|
|
|
2022-11-14 10:58:21 +01:00
|
|
|
|
- name: 'prometheus | server | create docker volume data'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
docker_volume:
|
|
|
|
|
name: prometheus_data
|
|
|
|
|
register: register_docker_volume_prometheus__prometheus_data
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-04-29 18:53:56 +02:00
|
|
|
|
|
2021-05-25 18:25:22 +02:00
|
|
|
|
- name: 'prometheus | server | create prometheus directory to /etc'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
file:
|
|
|
|
|
path: /etc/prometheus
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-04-29 18:53:56 +02:00
|
|
|
|
|
2021-05-25 18:25:22 +02:00
|
|
|
|
- name: 'prometheus | server | copy config prometheus yml'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
template:
|
2021-05-31 14:41:10 +02:00
|
|
|
|
src: conf/prometheus.yml.j2
|
2021-04-29 18:53:56 +02:00
|
|
|
|
dest: /etc/prometheus/prometheus.yml
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: 0644
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-05-26 12:06:05 +02:00
|
|
|
|
notify:
|
2022-11-14 10:58:21 +01:00
|
|
|
|
- 'prometheus | server | restart container'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
|
2022-11-14 11:05:19 +01:00
|
|
|
|
- name: 'prometheus | server | deploy container'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
docker_container:
|
|
|
|
|
name: prometheus
|
|
|
|
|
hostname: '{{ inventory_hostname }}'
|
2021-09-30 12:25:21 +02:00
|
|
|
|
image: prom/prometheus:{{ prometheus_server_version }}
|
2021-04-29 18:53:56 +02:00
|
|
|
|
volumes:
|
|
|
|
|
- /etc/prometheus/:/etc/prometheus/
|
|
|
|
|
- prometheus_data:/prometheus
|
|
|
|
|
command:
|
|
|
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
|
|
|
- '--storage.tsdb.path=/prometheus'
|
2021-10-01 17:13:20 +02:00
|
|
|
|
- '--storage.tsdb.retention.time={{ prometheus_retention_time }}'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
|
|
|
|
|
- '--web.console.templates=/usr/share/prometheus/consoles'
|
|
|
|
|
- '--web.enable-admin-api'
|
|
|
|
|
networks:
|
2023-01-27 16:51:27 +01:00
|
|
|
|
- { name: {{ prometheus_docker_network }} }
|
2021-04-29 18:53:56 +02:00
|
|
|
|
ports:
|
|
|
|
|
- "9090:9090"
|
|
|
|
|
log_driver: syslog
|
|
|
|
|
log_options:
|
|
|
|
|
tag: docker_prometheus
|
|
|
|
|
restart_policy: 'unless-stopped'
|
2022-11-11 23:51:52 +01:00
|
|
|
|
pull: '{{ prometheus_docker_pull }}'
|
2021-10-01 16:20:55 +02:00
|
|
|
|
etc_hosts: '{{ prometheus_nodes_ip }}'
|
2022-11-16 11:47:48 +01:00
|
|
|
|
tags: ['prometheus_server']
|
2021-05-26 12:06:05 +02:00
|
|
|
|
notify:
|
2022-11-14 10:58:21 +01:00
|
|
|
|
- 'prometheus | server | restart container'
|