Compare commits

..

23 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
d3e99ef12b Rearrange playbooks. Add EDA 2023-12-20 17:50:56 -05:00
39f379ae1e fix order 2023-12-20 14:47:35 -05:00
e0732bb8bd Force overwrite 2023-12-20 14:46:06 -05:00
a6dcf660b6 Temporary workaround 2023-12-20 14:33:03 -05:00
6dca08d9d8 Eighth times a charm... 2023-12-20 14:05:53 -05:00
57f65f81c9 Fix artifact URL 2023-12-20 14:04:39 -05:00
e651d2c21f FIx URL 2023-12-20 14:03:22 -05:00
37114c3eb1 Simplify process 2023-12-20 14:00:55 -05:00
1073ce1fb1 Don't need root 2023-12-20 13:55:50 -05:00
7b1fa91b41 Fix cleanup 2023-12-20 13:53:47 -05:00
c727a81986 Fix paths 2023-12-20 13:52:47 -05:00
10 changed files with 80 additions and 40 deletions

4
.gitignore vendored
View File

@@ -268,4 +268,6 @@ context/
collections/ansible_collections/ collections/ansible_collections/
.vault_password .vault_password
secrets.yml secrets.yml
.swp .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

@@ -1,38 +0,0 @@
---
- name: Deploy BAB Frontend Application
hosts: bab1.mgmt.toal.ca
become: true
vars:
artifact_version: 0.0.2
artifact_job: 10
artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/10/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }}
tasks:
- name: Download zip file from url
ansible.builtin.get_url:
url: "{{ artifact_url }}"
dest: /tmp/BABFrontend.zip
mode: '0644'
- name: Unzip file to temp directory
ansible.builtin.unarchive:
src: /tmp/BABFrontend.zip
dest: /tmp
remote_src: true
- name: Extract tgz file to nginx directory
ansible.builtin.unarchive:
src: /tmp/build-artifact-{{ artifact_version}}.{{ artifact_job}}/build-{{ artifact_version }}.tar.gz
dest: /usr/share/nginx/html
remote_src: true
- name: Cleanup temp directory
ansible.builtin.file:
path: /tmp/build-artifact-{{ artifact_version }}.{{ artifact_job }}
state: absent
- name: Clean up artifact download
ansible.builtin.file:
path: /tmp/BABFrontend.zip
state: absent

View File

@@ -0,0 +1,36 @@
---
- name: Deploy BAB Frontend Application
hosts: bab1.mgmt.toal.ca
become: false
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: /{{ tempdir.path }}/BABFrontend.zip
mode: '0644'
# Temporary until this drops: https://github.com/ansible/ansible/issues/81092
- 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: 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: "{{ 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

@@ -0,0 +1,20 @@
---
- name: Listen for Gitea Webhooks
hosts: all
sources:
- name: Ansible webhook listener
ansible.eda.webhook:
port: 5000
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 }}"