Skip to content
Snippets Groups Projects
Commit b46f8c23 authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-playbooks/general#85 Linting

parent b13621a4
Branches
No related tags found
No related merge requests found
alerta_ui_version: '7.0.1' alerta_ui_version: 7.0.1
- name: "Restart uwsgi" - name: Restart uwsgi
service: service:
name: 'uwsgi' name: uwsgi
state: 'restarted' state: restarted
--- ---
# file: roles/alerta/tasks/alerta.yml # file: roles/alerta/tasks/alerta.yml
- name: "Ensure packages" - name: Ensure packages
apt: apt:
pkg: '{{ packages }}' pkg: '{{ packages }}'
state: 'present' state: present
vars: vars:
packages: packages:
- 'python-pip' - python-pip
- 'python-dev' - python-dev
- 'python3-dev' - python3-dev
- 'libpq-dev' - libpq-dev
- name: "Ensure PIP packages" - name: Ensure PIP packages
pip: pip:
name: '{{ packages }}' name: '{{ packages }}'
state: 'present' state: present
vars: vars:
packages: packages:
- 'alerta-server' - alerta-server
- 'alerta' - alerta
- 'uwsgi' - uwsgi
- 'python-gitlab' - python-gitlab
- name: "Remove directories for web UI" - name: Remove directories for web UI
file: file:
path: '{{ item }}' path: '{{ item }}'
state: 'absent' state: absent
with_items: with_items:
- '/var/www/alerta' - /var/www/alerta
- '/tmp/angular-alerta-webui-master' - /tmp/angular-alerta-webui-master
# docker run -d -v "/var/www/alerta/config.json:/usr/share/nginx/html/config.json" --restart=always -it -p 8999:80 --name alerta-beta alerta/alerta-beta # docker run -d -v "/var/www/alerta/config.json:/usr/share/nginx/html/config.json" --restart=always -it -p 8999:80 --name alerta-beta alerta/alerta-beta
- name: "Download and extract web UI" - name: Download and extract web UI
unarchive: unarchive:
src: 'https://github.com/alerta/angular-alerta-webui/archive/v{{ alerta_ui_version }}.zip' src: https://github.com/alerta/angular-alerta-webui/archive/v{{ alerta_ui_version }}.zip
dest: '/tmp' dest: /tmp
remote_src: yes remote_src: yes
- name: "Move new web UI" - name: Move new web UI
command: 'mv /tmp/angular-alerta-webui-{{ alerta_ui_version }}/app /var/www/alerta' command: mv /tmp/angular-alerta-webui-{{ alerta_ui_version }}/app /var/www/alerta
args: args:
creates: '/var/www/alerta' creates: /var/www/alerta
removes: '/tmp/angular-alerta-webui-{{ alerta_ui_version }}/app' removes: /tmp/angular-alerta-webui-{{ alerta_ui_version }}/app
- name: "Copy wsgi.py" - name: Copy wsgi.py
template: template:
src: 'wsgi.py' src: wsgi.py
dest: '/var/www/alerta/wsgi.py' dest: /var/www/alerta/wsgi.py
- name: "Copy uwsgi.ini" - name: Copy uwsgi.ini
template: template:
src: 'uwsgi.ini' src: uwsgi.ini
dest: '/etc/uwsgi.ini' dest: /etc/uwsgi.ini
- name: "Copy uwsgi.service" - name: Copy uwsgi.service
template: template:
src: 'uwsgi.service' src: uwsgi.service
dest: '/etc/systemd/system/uwsgi.service' dest: /etc/systemd/system/uwsgi.service
- name: "Prepare uwsgi for autostart" - name: Prepare uwsgi for autostart
systemd: systemd:
name: 'uwsgi' name: uwsgi
state: 'restarted' state: restarted
enabled: yes enabled: yes
daemon_reload: yes daemon_reload: yes
- name: "Copy nginx default config" - name: Copy nginx default config
template: template:
src: 'nginx.default' src: nginx.default
dest: '/etc/nginx/sites-available/default' dest: /etc/nginx/sites-available/default
notify: notify:
- "Restart nginx" - "Restart nginx"
- name: "Copy config.js" - name: Copy config.js
template: template:
src: '{{ item }}' src: '{{ item }}'
dest: '/var/www/alerta/{{ item }}' dest: /var/www/alerta/{{ item }}
with_items: with_items:
- 'config.js' - config.js
- 'config.json' - config.json
- name: "Copy alertad.conf" - name: Copy alertad.conf
template: template:
src: 'alertad.conf' src: alertad.conf
dest: '/etc/alertad.conf' dest: /etc/alertad.conf
notify: notify:
- "Restart uwsgi" - "Restart uwsgi"
- name: "Configure root CLI" - name: Configure root CLI
template: template:
src: 'alerta.conf' src: alerta.conf
dest: '/root/.alerta.conf' dest: /root/.alerta.conf
- name: "Configure crontabs" - name: Configure crontabs
cron: cron:
name: '{{ item.name }}' name: '{{ item.name }}'
minute: '{{ item.minute }}' minute: '{{ item.minute }}'
job: '{{ item.job }} >/dev/null 2>&1' job: '{{ item.job }} >/dev/null 2>&1'
disabled: '{{ crons_disabled|default(false) }}' disabled: '{{ crons_disabled|default(false) }}'
with_items: with_items:
- name: 'Heartbeats to Alert' - name: Heartbeats to Alert
minute: '*/3' minute: */3
job: '/usr/local/bin/alerta heartbeats --alert' job: /usr/local/bin/alerta heartbeats --alert
- name: 'Alerta Housekeeping' - name: Alerta Housekeeping
minute: '0' minute: 0
job: '/usr/local/bin/alerta housekeeping' job: /usr/local/bin/alerta housekeeping
tags: 'cron' tags:
- cron
- name: "Copy Gitlab plugin"
- name: Copy Gitlab plugin
template: template:
src: 'gitlab/{{ item }}' src: gitlab/{{ item }}
dest: '/tmp/{{ item }}' dest: /tmp/{{ item }}
with_items: with_items:
- 'alerta_gitlab.py' - alerta_gitlab.py
- 'setup.py' - setup.py
tags: 'plugin' tags:
- plugin
- name: "Install Gitlab plugin" - name: Install Gitlab plugin
command: 'python3 setup.py install' command: python3 setup.py install
args: args:
chdir: '/tmp' chdir: /tmp
tags: 'plugin' tags:
- plugin
- name: "Copy favicon.ico" - name: Copy favicon.ico
copy: copy:
src: '{{ inventory_dir }}/files/favicon.ico' src: '{{ inventory_dir }}/files/favicon.ico'
dest: '/var/www/alerta/favicon.ico' dest: /var/www/alerta/favicon.ico
...@@ -5,16 +5,20 @@ ...@@ -5,16 +5,20 @@
--- ---
# file: roles/alerta/tasks/main.yml # file: roles/alerta/tasks/main.yml
- name: "Alerta Role" - name: Alerta Role
set_fact: role_alerta_started=true set_fact:
tags: 'always' role_alerta_started: yes
tags:
- always
- block: - block:
- import_tasks: alerta.yml - import_tasks: alerta.yml
- name: 'Remember that this role had been run' - name: Remember that this role had been run
set_fact: role_alerta_completed=true set_fact:
tags: 'always' role_alerta_completed: yes
tags:
- always
when: '"alerta" not in excluded_roles and role_alerta_completed is not defined' when: not excluded_roles or "alerta" not in excluded_roles and role_alerta_completed is not defined
...@@ -48,7 +48,7 @@ class GitlabIssue(PluginBase): ...@@ -48,7 +48,7 @@ class GitlabIssue(PluginBase):
raw_data = alert.raw_data raw_data = alert.raw_data
issue = project.issues.create({ issue = project.issues.create({
'title': alert.text[0:128], 'title': alert.text[0:128],
'description': '{}/alert/{}\n\nService: {}\n\nOrigin: {}\n\n```\n{}\n```\n'.format(ALERTA_URL, alert.id, alert.service, alert.origin, raw_data) 'description': {}/alert/{}\n\nService: {}\n\nOrigin: {}\n\n```\n{}\n```\n.format(ALERTA_URL, alert.id, alert.service, alert.origin, raw_data)
}) # type: gitlab.Issue }) # type: gitlab.Issue
alert.attributes['issue_iid'] = issue.id alert.attributes['issue_iid'] = issue.id
alert.attributes['gitlabUrl'] = '<a href="{}" target="_blank">Issue #{}</a>'.format( alert.attributes['gitlabUrl'] = '<a href="{}" target="_blank">Issue #{}</a>'.format(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment