blob: 183a4399cb756733cd96464ec61c50d52f1dcc13 (
plain)
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
|
---
- block:
- name: get start time (epoch+milliseconds)
set_fact:
time_start: "{{ lookup('pipe', 'date +%s%N | head -c 13' ) | int }}"
- name: set tags
set_fact:
grafana_tags: "{{ [ inventory_hostname ] }}"
- name: add inpod in tags
set_fact:
grafana_tags: "{{ grafana_tags + [ inpod ] }}"
when: inpod is defined
- name: "Create a grafana annotation"
uri:
url: "{{ grafana.api | regex_replace('\\/$', '') }}/annotations"
method: POST
status_code: 200
body_format: "json"
body: "{{
{
'time': time_start | int,
'isRegion': true,
'timeEnd': (time_start | int + 10000000),
'tags': grafana_tags,
'title': step,
'text': text
}
}}"
headers:
Content-Type: "application/json"
Accept: "application/json"
Authorization: "Bearer {{ grafana.token }}"
register: grafana_events
vars:
text:
"<a href=\"{{ pipeline_url }}\">{{ step }}</a> running"
delegate_to: "{{ grafana.jumphost }}"
ignore_errors: true
|