/
playbook.yml
154 lines (143 loc) · 3.32 KB
/
playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
- hosts: grafana-dockerhost
tasks:
- name: makes sure /conf exists
file:
path: "{{ item }}"
state: directory
recurse: yes
with_items:
- "{{ conf_dir }}"
- "{{ data_dir }}"
- "{{ grafana_data_dir }}"
tags:
- demo
- dir
- conf
- templates
- data
- name: change ownership of data dir
file:
path: "{{ data_dir }}"
state: directory
recurse: yes
owner: nfsnobody
group: nfsnobody
tags:
- perms
- demo
- dir
- data
- name: change ownership of data dir
file:
path: "{{ grafana_data_dir }}"
state: directory
recurse: yes
owner: "{{ grafana_owner }}"
group: root
tags:
- grafana
- demo
- dir
- data
- name: template prometheus config
template:
src: etc/prometheus.yml
dest: "{{ conf_dir }}/prometheus.yml"
tags:
- templates
- prometheus
- demo
- conf
- name: template blackbox config
template:
src: etc/blackbox.yml
dest: "{{ conf_dir }}/blackbox.yml"
tags:
- templates
- blackbox
- conf
- name: container itself
docker_container:
name: prometheus_demo
restart_policy: always
restart: yes
image: prom/prometheus
ports:
- "{{ service_port }}:9090/tcp"
volumes:
- "{{ conf_dir }}/prometheus.yml:/etc/prometheus/prometheus.yml"
- "{{ data_dir }}:/prometheus"
entrypoint: 'prometheus --storage.tsdb.retention.time=365d --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus'
tags:
- demo
- container
- prometheus
- name: prometheus black box exporter
docker_container:
name: blackbox_demo
image: prom/blackbox-exporter:master
restart_policy: always
restart: yes
privileged: yes
ports:
- "{{ blackbox_exporter_port}}:9115"
volumes:
- "{{ conf_dir }}:/config:ro"
command:
- '--config.file=/config/blackbox.yml'
tags:
- container
- blackbox
- name: snmp exporter
docker_container:
name: snmp_demo
image: prom/snmp-exporter
ports:
- "{{ snmp_exporter_port }}:9116/tcp"
tags:
- snmp
- blackbox
- name: grafana container
docker_container:
name: grafana_demo
restart_policy: always
image: grafana/grafana
ports:
- "{{ grafana_port }}:3000/tcp"
volumes:
- "{{ conf_dir }}/grafana:/var/lib/grafana"
env:
GF_INSTALL_PLUGINS: grafana-clock-panel,grafana-simple-json-datasource
tags:
- grafana
- container
- name: open firewall port
firewalld:
port: "{{ item }}"
permanent: yes
state: enabled
with_items:
- "{{ service_port }}/tcp"
- "{{ blackbox_exporter_port }}/tcp"
- "{{ snmp_exporter_port }}/tcp"
- "{{ grafana_port }}/tcp"
tags:
- demo
- firewall
- name: restart firewall
shell: firewall-cmd --reload
tags:
- demo
- firewall
- restart
- name: restart prometheus stack just in case
shell: "docker restart {{ item }}"
with_items:
- prometheus_demo
- blackbox_demo
- snmp_demo
- grafana_demo
tags:
- demo
- restart