--- - name: prepare storage volume for alerta when: alerta_storage is defined vars: storage_volume: "{{ alerta_storage | combine({'dest': alerta_base_path}) }}" include_role: name: "storage/{{ alerta_storage.type }}/volume" - 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:{{ alerta_web_version }} {% if 'prometheus' in alerta_plugins %} 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 {% endif %} {% if alerta_mailer is defined %} RUN set -x \ && /venv/bin/pip install redis=={{ _alerta_pip[alerta_web_version].redis_version }} \ && /venv/bin/pip install git+https://github.com/alerta/alerta-contrib.git@{{ _alerta_pip[alerta_web_version].contrib_mailer_git_hash }}#subdirectory=integrations/mailer \ && echo "" >> /app/supervisord.conf.j2 \ && echo "[program:mailer]" >> /app/supervisord.conf.j2 \ && echo "command=alerta-mailer" >> /app/supervisord.conf.j2 \ && echo "redirect_stderr=true" >> /app/supervisord.conf.j2 USER root RUN set -x \ && sed 's/--scope "write:alerts"/--scope "write:alerts" --scope "write:heartbeats"/' -i /usr/local/bin/docker-entrypoint.sh USER 1001 {% endif %} {% if alerta_hearbeat_force_severity is defined %} RUN set -x \ && sed 's/want_severity = .*/want_severity = severity/' -i /venv/lib/python3.8/site-packages/alertaclient/commands/cmd_heartbeats.py ENV HEARTBEAT_SEVERITY={{ alerta_hearbeat_force_severity }} {% endif %} dest: "{{ alerta_base_path }}/build/Dockerfile" register: alerta_custom_image_docker - name: build custom image docker_image: name: "alerta/alerta-web:{{ alerta_web_version }}-custom" state: present force_source: "{{ alerta_custom_image_docker is changed }}" source: build build: path: "{{ alerta_base_path }}/build" network: host pull: yes - name: install config templates loop: - alertad - alerta template: src: "{{ item }}.conf.j2.j2" dest: "{{ alerta_base_path }}/config/{{ item }}.conf.j2" 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.conf.j2" 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 - name: configure nginx vhost when: alerta_web_nginx_vhost is defined vars: nginx_vhost: "{{ alerta_web_nginx_vhost }}" include_role: name: nginx/vhost