-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-grafana.yml
137 lines (127 loc) · 3.6 KB
/
deploy-grafana.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
---
- name: Deploy grafana to monitoring server
hosts: monitoring
become: true
gather_facts: False
vars_files:
- "vars/main.yml"
- "vars/credentials.yml"
tasks:
- name: Assures directories exists
file: path="{{ item }}" state=directory owner=root group=root
with_items:
- "/etc/grafana/provisioning/dashboards"
- "/etc/grafana/provisioning/datasources"
- "/var/lib/grafana"
- "/var/log/grafana"
- "/var/lib/grafana/plugins"
- "/var/lib/grafana/png"
- "/var/lib/grafana/dashboards"
- "/var/lib/postgresql/data"
tags:
- grafana
- postgres
- name: Copy configurations
template: src="./config/grafana/grafana.ini"
dest="/etc/grafana/grafana.ini"
owner=root
group=root
tags:
- grafana
- name: Copy dashboard config
template: src="./config/grafana/dashboards.yaml"
dest="/etc/grafana/provisioning/dashboards/dashboards.yaml"
owner=root
group=root
tags:
- grafana
- name: Copy dashboard
template: src="./config/grafana/{{ item }}.json"
dest="/var/lib/grafana/dashboards/{{ item }}.json"
owner=root
group=root
with_items:
- docker
- linux
- mongodb
- redis
tags:
- grafana
- name: Copy influxdb datasorce
template: src="./config/grafana/datasources.yaml"
dest="/etc/grafana/provisioning/datasources/datasources.yaml"
owner=root
group=root
tags:
- grafana
- name: "Pull PostgreSQL docker image"
docker_image:
state: present
source: pull
force_source: yes
name: "postgres:11.3"
tag: "11.3"
tags:
- postgres
- name: "Launch PostgreSQL container"
docker_container:
name: postgres
image: postgres:11.3
state: started
restart_policy: always
ports:
- "5432:5432"
networks:
- name: "{{ monitoring_network_name }}"
volumes:
- /var/lib/postgresql/data:/var/lib/postgresql/data
env:
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
tags:
- postgres
- name: "Pull Grafana docker image"
docker_image:
state: present
source: pull
force_source: yes
name: "grafana/grafana:6.2.5"
tag: "6.2.5"
tags:
- grafana
- name: Make sure psycopg2 is installed
apt:
name:
- python3-psycopg2
- python-psycopg2
state: latest
tags:
- postgres
- name: create postgres database
postgresql_db:
login_host: "localhost"
login_password: "{{ postgres_password }}"
login_user: "{{ postgres_user }}"
name: "{{ postgres_db_name }}"
port: "5432"
tags:
- postgres
- name: "Launch Grafana container"
docker_container:
name: grafana
image: grafana/grafana:6.2.5
state: started
restart_policy: always
ports:
- "3300:3000"
networks:
- name: "{{ monitoring_network_name }}"
volumes:
- /var/lib/grafana:/var/lib/grafana
- /etc/grafana:/etc/grafana
- /var/log/grafana:/var/log/grafana
env:
GF_SECURITY_ADMIN_USER: "{{ gf_admin_user }}"
GF_SECURITY_ADMIN_PASSWORD: "{{ gf_admin_password }}"
tags:
- grafana