-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-panel.yml
57 lines (56 loc) · 1.74 KB
/
add-panel.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
---
- name: add panel grafana dashboard
hosts: localhost
gather_facts: no
tasks:
##Download json dashboard
- name: Download Grafana dashboard
grafana_dashboard:
grafana_url: {{URL}}
grafana_api_key: {{api_key}}
uid: {{uid_grafana}}
state: export
path: {{path}}
###convert json raw to pretty json
- name: convert to pretty json
shell: python3 -m json.tool {{path}} > {{path_1}} #convert into pretty json
###replace var
- name: copy file for editing
shell: 'cp {{path}} {{path_1}}'
- name: replace method to change string in file name job name in query
replace:
path: {{path}}
regexp: 'code_job'
replace: "{{ job }}"
- name: replace method to change string in file name in tittle and row
replace:
path: {{path}}
regexp: 'code_tittle'
replace: "{{ tittle }}"
- name: replace method to change string in file name job 2
replace:
path: {{path}}
regexp: 'code_boj'
replace: "{{ boj }}"
- name: replace method to change string in file name in title 2
replace:
path: {{path}}
regexp: 'code_judul'
replace: "{{ judul }}"
- name: replace method to change string in file name in id panel
replace:
path: {{path}}
regexp: "code_id_panel"
replace: "{{ 230 | random }}"
#SED append data spesific line
- name: Create file for import to grafana
shell: sed '142r {{path}}' {{path}} > {{path_1}}
#import dashboard
- name: Import Grafana dashboard
grafana_dashboard:
grafana_url: {{url}}
grafana_api_key: {{key}}
state: present
overwrite: yes
folder: {{url}}
path: {{path}}