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-02-06 15:44:42 +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:
|
2023-02-09 18:01:15 +01:00
|
|
|
- 'grafana-prometheus | server | restart container'
|
2021-04-29 18:53:56 +02:00
|
|
|
|
2023-02-09 18:01:15 +01:00
|
|
|
- name: "grafana-prometheus | create docker-compose directory"
|
|
|
|
file:
|
|
|
|
path: /opt/docker-compose/grafana-prometheus
|
|
|
|
state: directory
|
|
|
|
mode: '0755'
|
|
|
|
tags: [ 'grafana-prometheus', 'prometheus_server' ]
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | copy docker-compose file"
|
|
|
|
template:
|
|
|
|
src: compose/grafana-prometheus.yml.j2
|
|
|
|
dest: /opt/docker-compose/grafana-prometheus/docker-compose.yml
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify: "grafana-prometheus | server | restart container"
|
|
|
|
tags: [ 'grafana-prometheus' ]
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | create grafana.ini file"
|
|
|
|
file:
|
|
|
|
path: /opt/docker-compose/grafana-prometheus/grafana.ini
|
|
|
|
owner: '1000'
|
|
|
|
group: '1000'
|
|
|
|
mode: '0750'
|
|
|
|
state: touch
|
|
|
|
notify: "grafana-prometheus | server | restart container"
|
|
|
|
tags: [ 'grafana-prometheus' ]
|
|
|
|
ignore_errors: '{{ ansible_check_mode }}'
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | import grafana provisioned datasources"
|
|
|
|
synchronize:
|
|
|
|
src: "{{ grafana_provisioned_datasources_path }}"
|
|
|
|
dest: /opt/docker-compose/grafana-prometheus/
|
|
|
|
when: grafana_provisioned_datasources_path is defined
|
|
|
|
notify: "grafana-prometheus | server | restart container"
|
|
|
|
tags: [ 'grafana-prometheus' ]
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | import grafana provisioned dashboards"
|
|
|
|
synchronize:
|
|
|
|
src: "{{ grafana_provisioned_dashboards_path }}"
|
|
|
|
dest: /opt/docker-compose/grafana-prometheus/
|
|
|
|
when: grafana_provisioned_datasources_path is defined
|
|
|
|
notify: "grafana-prometheus | server | restart container"
|
|
|
|
tags: [ 'grafana-prometheus' ]
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | install unit file to systemd"
|
|
|
|
vars:
|
|
|
|
exporter: "grafana-prometheus"
|
|
|
|
template:
|
|
|
|
src: systemd/docker-compose.service.j2
|
|
|
|
dest: /etc/systemd/system/docker-compose@grafana-prometheus.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
tags: [ 'grafana-prometheus' ]
|
|
|
|
|
|
|
|
- name: "grafana-prometheus | enable service"
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: docker-compose@grafana-prometheus
|
|
|
|
enabled: true
|
|
|
|
ignore_errors: '{{ ansible_check_mode }}'
|
|
|
|
tags: [ 'grafana-prometheus' ]
|