-
Notifications
You must be signed in to change notification settings - Fork 2
/
monitoring.yaml
98 lines (96 loc) · 4.34 KB
/
monitoring.yaml
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
- hosts: master
become: yes
become_user: root
tasks:
- name: Creating monitoring namespace
shell: kubectl create namespace monitoring >> monitoring_ns_created.info
args:
chdir: $HOME
creates: monitoring_ns_created.info
become_user: ubuntu
- name: Making infrastructure directory in gluster storage
file:
path: /mnt/shared-directory/infrastructure
state: directory
mode: 0777
run_once: true
- name: Making grafana directory in gluster storage
file:
path: /mnt/shared-directory/infrastructure/grafana
state: directory
mode: 0777
run_once: true
- name: Making prometheus directory in gluster storage
file:
path: /mnt/shared-directory/infrastructure/prometheus
state: directory
mode: 0777
run_once: true
- name: Making alertmanager directory in gluster storage
file:
path: /mnt/shared-directory/infrastructure/alertmanager
state: directory
mode: 0777
run_once: true
- name: Making pushgateway directory in gluster storage
file:
path: /mnt/shared-directory/infrastructure/pushgateway
state: directory
mode: 0777
run_once: true
- name: Copying PV and PVC to installation directory
become_user: ubuntu
copy:
src: monitoring
dest: ~/
- name: Creating Monitoring Persistent Storage
become_user: ubuntu
shell: kubectl create -f {{ item.yaml }} >> monitoring_{{ item.file }}.info
with_items:
- { yaml: '~/monitoring/volume/alertmanager-volume.yaml', file: 'alertmanager-volume' }
- { yaml: '~/monitoring/volume/pushgateway-volume.yaml', file: 'pushgateway-volume' }
- { yaml: '~/monitoring/volume/prometheus-volume.yaml', file: 'prometheus-volume' }
- { yaml: '~/monitoring/volume/grafana-volume.yaml', file: 'grafana-volume' }
args:
chdir: $HOME
creates: monitoring_{{ item.file }}.info
- name: Prepairing Prometheus Deployment
become_user: ubuntu
replace:
path: ~/monitoring/prometheus.yaml
regexp: "{{ item.regexp }}"
replace: "{{ item.var }}"
with_items:
- { regexp: 'alertmanager_ingress_bool', var: "{{ alertmanager_ingress_bool }}" }
- { regexp: 'alertmanager_address_http$', var: "{{ alertmanager_address_http }}" }
- { regexp: 'alertmanager_address_https', var: "{{ alertmanager_address_https }}" }
- { regexp: 'alertmanager_certificate', var: "{{ alertmanager_certificate }}" }
- { regexp: 'prometheus_ingress_bool', var: "{{ prometheus_ingress_bool }}" }
- { regexp: 'prometheus_address_http$', var: "{{ prometheus_address_http }}" }
- { regexp: 'prometheus_address_https', var: "{{ prometheus_address_https }}" }
- { regexp: 'prometheus_certificate', var: "{{ prometheus_certificate }}" }
- { regexp: 'pushgateway_ingress_bool', var: "{{ pushgateway_ingress_bool }}" }
- { regexp: 'pushgateway_address_http$', var: "{{ pushgateway_address_http }}" }
- { regexp: 'pushgateway_address_https', var: "{{ pushgateway_address_https }}" }
- { regexp: 'pushgateway_certificate', var: "{{ pushgateway_certificate }}" }
- name: Prepairing Grafana Deployment
become_user: ubuntu
replace:
path: ~/monitoring/grafana.yaml
regexp: "{{ item.regexp }}"
replace: "{{ item.var }}"
with_items:
- { regexp: 'grafana_ingress_bool', var: "{{ grafana_ingress_bool }}" }
- { regexp: 'grafana_address_http$', var: "{{ grafana_address_http }}" }
- { regexp: 'grafana_address_https', var: "{{ grafana_address_https }}" }
- { regexp: 'grafana_certificate', var: "{{ grafana_certificate }}" }
- { regexp: 'grafanapw', var: "{{ grafana_admin_pw }}" }
- name: Deploying Monitoring
become_user: ubuntu
shell: helm install -f {{ item.yaml }} >> monitoring_{{ item.file }}.info
with_items:
- { yaml: '~/monitoring/prometheus.yaml stable/prometheus --namespace monitoring --name monitoring', file: 'prometheus_installed' }
- { yaml: '~/monitoring/grafana.yaml stable/grafana --namespace monitoring --name grafana', file: 'grafana_installed' }
args:
chdir: $HOME
creates: monitoring_{{ item.file }}.info