blob: 490f5e3d11c2e352991244f4fdab67dc203a02db (
plain) (
blame)
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
|
---
- name: create alerta subdirectories
loop:
- config
- postgres
- build
file:
path: "{{ alerta_base_path }}/{{ item }}"
state: directory
- name: generate Dockerfile for custom image
copy:
content: |
FROM alerta/alerta-web:8.7.0
RUN set -x \
&& sed 's/USE_AM_EXTERNALURL_FOR_SILENCES/ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES/' -i /venv/lib/python3.8/site-packages/alerta_prometheus.py \
&& /venv/bin/pip install redis==4.1.4 \
&& /venv/bin/pip install git+https://github.com/alerta/alerta-contrib.git@69d271ef9fe6542727ec4aa39fc8e0f797f1e8b1#subdirectory=integrations/mailer
dest: "{{ alerta_base_path }}/build/Dockerfile"
register: alerta_custom_image_docker
- name: build custom image
docker_image:
name: "alerta-web-with-mailer:8.7.0"
state: present
force_source: "{{ alerta_custom_image_docker is changed }}"
source: build
build:
path: "{{ alerta_base_path }}/build"
network: host
pull: yes
- name: install alertad config template
copy:
content: |
DEBUG = {{ '{{' }} 'True' if env.DEBUG else 'False' {{ '}}' }}
SECRET = "{{ '{{' }} env.SECRET_KEY {{ '}}' }}"
ALERT_TIMEOUT = 86400
HEARTBEAT_TIMEOUT = 7200
PLUGINS = ['reject', 'blackout', 'heartbeat', 'prometheus', 'amqp']
DEFAULT_ENVIRONMENT = 'unknown'
ALLOWED_ENVIRONMENTS = ['unknown', 'chaos-at-.*']
HEARTBEAT_EVENTS = ['PrometheusAlertmanagerE2eDeadManSwitch']
ALERTMANAGER_USERNAME = 'alerta'
ALERTMANAGER_PASSWORD = 'alerta'
ALERTMANAGER_SILENCE_FROM_ACK = True
ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES = True
AMQP_URL = 'redis://localhost:6379/'
dest: "{{ alerta_base_path }}/config/alertad.conf.j2"
## TODO: add key handling...
- name: install alerta-mailer config file
copy:
content: |
[alerta-mailer]
debug = True
key = aNqBsEyG0ynIKcc3e7acaBVBk5B793o_z7tvlsht
endpoint = http://localhost:8080/api
amqp_url = redis://localhost:6379
severities = critical, warning
smtp_host = 192.168.28.250
smtp_port = 25
smtp_starttls = False
skip_mta = False
mail_to = equinox@chaos-at-home.org
mail_from = noreply@chaos-at-home.org
email_type = text
mail_template = /app/email.tmpl
dashboard_url = http://192.168.32.1:8080
dest: "{{ alerta_base_path }}/config/alerta-mailer.conf"
mode: 0640
- name: install e-mail template
copy:
src: email.tmpl
dest: "{{ alerta_base_path }}/config/email.tmpl"
- name: install pod manifest
vars:
kubernetes_standalone_pod:
name: "alerta"
spec: "{{ lookup('template', 'pod-spec.yml.j2') }}"
mode: "0600"
config_hash_items:
- path: "{{ alerta_base_path }}/config/alertad.conf.j2"
properties:
- checksum
- path: "{{ alerta_base_path }}/config/alerta-mailer.conf"
properties:
- checksum
- path: "{{ alerta_base_path }}/config/email.tmpl"
properties:
- checksum
- path: "{{ alerta_base_path }}/build/Dockerfile"
properties:
- checksum
include_role:
name: kubernetes/standalone/pod
|