-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_service_checks.yml
100 lines (88 loc) · 3.12 KB
/
setup_service_checks.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
- hosts: localhost
name: "Creates or Update the AxonOps service checks"
become: false
connection: local
gather_facts: false
pre_tasks:
- name: Get the Org name
tags: always
ansible.builtin.set_fact:
org: "{{ lookup('env', 'AXONOPS_ORG') }}"
when: org is not defined
- name: Get the cluster name
tags: always
ansible.builtin.set_fact:
cluster: "{{ lookup('env', 'AXONOPS_CLUSTER') }}"
when: cluster is not defined
- name: Fail if no org
ansible.builtin.assert:
that:
- org is defined
- org | length > 1
- cluster is defined
- name: Initialize axonops_shell_check
tags: always
ansible.builtin.set_fact:
axonops_shell_check: "{{ axonops_shell_check | default([]) }}"
- name: Load organization-wide alert rules
tags: always
ansible.builtin.set_fact:
axonops_shell_check: "{{ axonops_shell_check + (lookup('file', item) | from_yaml).axonops_shell_check }}"
with_fileglob:
- "config/{{ org }}/service_checks.yml"
- name: Load cluster-specific alert rules
tags: always
ansible.builtin.set_fact:
axonops_shell_check: "{{ axonops_shell_check + (lookup('file', item) | from_yaml).axonops_shell_check }}"
with_fileglob:
- "config/{{ org }}/{{ cluster }}/service_checks.yml"
- name: Initialize axonops_tcp_check
tags: always
ansible.builtin.set_fact:
axonops_tcp_check: "{{ axonops_tcp_check | default([]) }}"
- name: Load organization-wide alert rules
tags: always
ansible.builtin.set_fact:
axonops_tcp_check: "{{ axonops_tcp_check + (lookup('file', item) | from_yaml).axonops_tcp_check }}"
with_fileglob:
- "config/{{ org }}/service_checks.yml"
- name: Load cluster-specific alert rules
tags: always
ansible.builtin.set_fact:
axonops_tcp_check: "{{ axonops_tcp_check + (lookup('file', item) | from_yaml).axonops_tcp_check }}"
with_fileglob:
- "config/{{ org }}/{{ cluster }}/service_checks.yml"
- name: Apply TCP Check on {{ org }}/{{ cluster }}
axonops.configuration.tcp_check:
org: "{{ org }}"
cluster: "{{ cluster }}"
present: "{{ item.present|default(true) }}"
name: "{{ item.name|default('') }}"
interval: "{{ item.interval }}"
timeout: "{{ item.timeout }}"
tcp: "{{ item.tcp }}"
with_items:
"{{ axonops_tcp_check }}"
tags:
- axonops_tcp_check
- tcp_check
- check
- tcp
- name: Apply Shell Check on {{ org }}/{{ cluster }}
axonops.configuration.shell_check:
org: "{{ org }}"
cluster: "{{ cluster }}"
present: "{{ item.present|default(true) }}"
name: "{{ item.name|default('') }}"
interval: "{{ item.interval }}"
timeout: "{{ item.timeout }}"
shell: "{{ item.shell|default('/bin/bash') }}"
script: "{{ item.script }}"
with_items:
"{{ axonops_shell_check }}"
tags:
- axonops_shell_check
- shell_check
- check
- shell
# code: language=ansible