Skip to content

Commit 59f00c1

Browse files
committed
Split alerta web console install tasks to new file
1 parent 9825098 commit 59f00c1

3 files changed

Lines changed: 36 additions & 48 deletions

File tree

tasks/install.yml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,8 @@
1111
state: present
1212
executable: pip3
1313

14-
- name: Install alerta server and alerta command-line tool
14+
- name: Install alerta base packages using pip
1515
pip:
16-
name: ['alerta', 'alerta-server', 'uwsgi']
16+
name: '{{ alerta_pip_packages }}'
1717
virtualenv: '{{ alerta_base_dir }}'
1818
state: present
19-
20-
- name: Create a wsgi python file
21-
copy:
22-
content: from alerta import app
23-
dest: '{{ alerta_base_dir }}/wsgi.py'
24-
25-
- name: Create alerta web console directory
26-
file:
27-
path: '{{ alerta_web_ui_dir }}'
28-
state: directory
29-
30-
- name: Get web console archive
31-
get_url:
32-
url: https://github.com/alerta/alerta-webui/releases/latest/download/alerta-webui.tar.gz
33-
dest: /tmp/alerta-webui.tar.gz
34-
35-
- name: Extract alerta web console
36-
unarchive:
37-
src: /tmp/alerta-webui.tar.gz
38-
dest: '{{ alerta_web_ui_dir }}'
39-
remote_src: true
40-
extra_opts: ['--strip-components=1']
41-
42-
- name: Configure alerta web console
43-
template:
44-
src: config.json.j2
45-
dest: '{{ alerta_web_ui_dir }}/config.json'
46-
47-
- name: Create uWsgi configuration file
48-
template:
49-
src: uwsgi.ini.j2
50-
dest: /etc/uwsgi.ini
51-
52-
- name: Configure alertad.conf
53-
template:
54-
src: alertad.conf.j2
55-
dest: /etc/alertad.conf
56-
notify: restart alerta
57-
58-
- name: Create a systemd configuration file for the alerta
59-
copy:
60-
src: alerta.service
61-
dest: /etc/systemd/system/alerta.service
62-
notify: restart alerta

tasks/main.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@
99
- "{{ ansible_distribution }}.yml"
1010
- "{{ ansible_os_family }}.yml"
1111

12-
- name: Define alerta_secretkey
12+
- name: Fail if alerta secretkey not defined
13+
fail:
14+
msg: alerta_secretkey must be defined if you enable alerta authentification
15+
when: alerta_auth_required | bool and alerta_secretkey == ''
16+
17+
- name: Define alerta_pip_packages
1318
set_fact:
14-
alerta_secretkey: '{{ lookup("password", "/tmp/alerta_secretkey length=32") }}'
19+
alerta_pip_packages: '{{ alerta_pip_base_packages +
20+
alerta_pip_depend_packages +
21+
alerta_pip_plugins_packages }}'
1522

1623
- import_tasks: install.yml
1724

25+
- import_tasks: configure.yml
26+
27+
- import_tasks: web-console.yml
28+
1829
- name: Start & enable Alerta
1930
systemd:
2031
name: alerta

tasks/web-console.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
- name: Create alerta web console directory
2+
file:
3+
path: '{{ alerta_web_ui_dir }}'
4+
state: directory
5+
6+
- name: Get web console archive
7+
get_url:
8+
url: 'https://github.com/alerta/alerta-webui/releases/download/v{{ alerta_web_console_version }}/alerta-webui.tar.gz'
9+
dest: /tmp/alerta-webui.tar.gz
10+
11+
- name: Extract alerta web console
12+
unarchive:
13+
src: /tmp/alerta-webui.tar.gz
14+
dest: '{{ alerta_web_ui_dir }}'
15+
remote_src: true
16+
extra_opts: ['--strip-components=1']
17+
18+
- name: Configure alerta web console
19+
template:
20+
src: config.json.j2
21+
dest: '{{ alerta_web_ui_dir }}/config.json'

0 commit comments

Comments
 (0)