Compare commits

..

12 Commits

Author SHA1 Message Date
c8485bc35b Add Alertmanager 2024-01-16 14:46:31 -05:00
51709f6ee9 Ignore vscode files 2024-01-01 19:29:01 -05:00
19f498e091 Update deploy workflow to use a tar in a zip 2024-01-01 11:31:32 -05:00
6e153d16b1 Fix typ 2023-12-30 00:32:13 -05:00
b905507bb8 Fix the vars 2023-12-30 00:25:52 -05:00
b69162d79e Remove Debug 2023-12-30 00:17:43 -05:00
a8c73b569a Update payload path 2023-12-30 00:06:35 -05:00
ed1bd120e4 Add debugging 2023-12-29 23:41:18 -05:00
79b2b6f28f Remove filter 2023-12-29 12:36:49 -05:00
fd576bef97 Update rulebook 2023-12-29 11:45:38 -05:00
dbcf8688a5 Remove temporary vars 2023-12-29 11:43:34 -05:00
e054cd2125 Update webhook 2023-12-29 11:34:34 -05:00
5 changed files with 56 additions and 15 deletions

2
.gitignore vendored
View File

@@ -269,3 +269,5 @@ collections/ansible_collections/
.vault_password
secrets.yml
.swp
# Ignore vscode
.vscode/

View File

@@ -1,3 +1,3 @@
{
"ansible.python.interpreterPath": "/var/home/ptoal/.virtualenvs/ansible/bin/python"
"ansible.python.interpreterPath": "/home/ptoal/.virtualenvs/ansible/bin/python"
}

View File

@@ -2,22 +2,35 @@
- name: Deploy BAB Frontend Application
hosts: bab1.mgmt.toal.ca
become: false
vars:
artifact_version: 0.0.2
artifact_job: 11
artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/{{ artifact_job }}/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }}
tasks:
- name: Create temporary directory
ansible.builtin.tempfile:
state: directory
suffix: .deploy
register: tempdir
- name: Download zip file from url
ansible.builtin.get_url:
url: "{{ artifact_url }}"
dest: /tmp/BABFrontend.zip
dest: /{{ tempdir.path }}/BABFrontend.zip
mode: '0644'
# Temporary until this drops: https://github.com/ansible/ansible/issues/81092
- name: Unzip file to web dir
ansible.builtin.command: unzip -o /tmp/BABFrontend.zip -d /usr/share/nginx/html/
- name: Unzip downloaded file
ansible.builtin.unarchive:
src: "{{ tempdir.path }}/BABFrontend.zip"
dest: "{{ tempdir.path }}"
list_files: true
remote_src: true
register: unzip_result
- name: Clean up artifact download
- name: Extract tar into /usr/share/nginx/html/
ansible.builtin.unarchive:
src: "{{ unzip_result.dest }}/{{ unzip_result.files[0] }}" # We expect exactly one tar file to be in the artifact.
dest: /usr/share/nginx/html/
remote_src: true
- name: Clean up
ansible.builtin.file:
path: /tmp/BABFrontend.zip
path: "{{ tempdir.path }}"
state: absent

View File

@@ -0,0 +1,20 @@
---
- name: Listen for Alertmanager events
hosts: all
sources:
- name: Ansible Alertmanager listener
ansible.eda.alertmanager:
port: 9100
host: 0.0.0.0
rules:
- name: Run Template
condition:
all:
- event.payload.data.artifact_url is defined
action:
run_job_template:
name: bab-deploy-application
organization: OYS
job_args:
extra_vars:
artifact_url: "{{ event.payload.data.artifact_url }}"

View File

@@ -6,9 +6,15 @@
ansible.eda.webhook:
port: 5000
host: 0.0.0.0
rules:
- name: Show payload
condition: 1 == 1
- name: Run Template
condition:
all:
- event.payload.data.artifact_url is defined
action:
debug:
run_job_template:
name: bab-deploy-application
organization: OYS
job_args:
extra_vars:
artifact_url: "{{ event.payload.data.artifact_url }}"