-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_log_alerts.yml
75 lines (67 loc) · 2.51 KB
/
setup_log_alerts.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
- hosts: localhost
name: "Creates or Update the AxonOps log alerts"
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_log_alert_rule
tags: always
ansible.builtin.set_fact:
axonops_log_alert_rule: "{{ axonops_log_alert_rule | default([]) }}"
- name: Load organization-wide alert rules
tags: always
ansible.builtin.set_fact:
axonops_log_alert_rule: "{{ axonops_log_alert_rule + (lookup('file', item) | from_yaml).axonops_log_alert_rule }}"
with_fileglob:
- "config/{{ org }}/log_alert_rules.yml"
- name: Load cluster-specific alert rules
tags: always
ansible.builtin.set_fact:
axonops_log_alert_rule: "{{ axonops_log_alert_rule + (lookup('file', item) | from_yaml).axonops_log_alert_rule }}"
with_fileglob:
- "config/{{ org }}/{{ cluster }}/log_alert_rules.yml"
- name: Install log alerts on {{ org }}/{{ cluster }}
axonops.configuration.log_alert_rule:
org: "{{ org }}"
cluster: "{{ cluster }}"
name: "{{ item.name }}"
content: "{{ item.content |default('') }}"
operator: "{{ item.operator |default('>=')}}"
description: "{{ item.description |default('')}}"
level: "{{ item.level |default('')}}"
type: "{{ item.type |default('')}}"
source: "{{ item.source |default('')}}"
warning_value: "{{ item.warning_value }}"
critical_value: "{{ item.critical_value }}"
duration: "{{ item.duration }}"
routing: "{{ item.routing|default(omit) }}"
present: "{{ item.present|default(true) }}"
dc: "{{ item.dc|default([]) }}"
rack: "{{ item.rack|default([]) }}"
host_id: "{{ item.host_id|default([]) }}"
with_items:
"{{ axonops_log_alert_rule }}"
no_log: "{{ false if enable_logging is defined and enable_logging else true }}"
tags:
- axonops_log_alert_rule
- log_alert_rule
- alert_rule
- alert
- rule
# code: language=ansible