From c727a8198603633ba0dad92db28cde818f77ea8a Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 13:52:47 -0500 Subject: [PATCH 01/11] Fix paths --- deploy_application.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/deploy_application.yml b/deploy_application.yml index 4f041c7..ecdb449 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -22,15 +22,10 @@ - name: Extract tgz file to nginx directory ansible.builtin.unarchive: - src: /tmp/build-artifact-{{ artifact_version}}.{{ artifact_job}}/build-{{ artifact_version }}.tar.gz + src: /tmp/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 -- 2.49.1 From 7b1fa91b41c7bdb99e09c43e6af1e2205d2322d4 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 13:53:47 -0500 Subject: [PATCH 02/11] Fix cleanup --- deploy_application.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index ecdb449..b3134f7 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -26,8 +26,12 @@ dest: /usr/share/nginx/html remote_src: true + - name: Cleanup temp file + ansible.builtin.file: + path: /tmp/build-artifact-{{ artifact_version }}.tar.gz + state: absent + - name: Clean up artifact download ansible.builtin.file: path: /tmp/BABFrontend.zip state: absent - -- 2.49.1 From 1073ce1fb1d23ff6dfd605a04a52c15faa179a35 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 13:55:50 -0500 Subject: [PATCH 03/11] Don't need root --- deploy_application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index b3134f7..9742336 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -1,7 +1,7 @@ --- - name: Deploy BAB Frontend Application hosts: bab1.mgmt.toal.ca - become: true + become: false vars: artifact_version: 0.0.2 artifact_job: 10 -- 2.49.1 From 37114c3eb1df300770b59e9ca76d166ea825adb0 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:00:55 -0500 Subject: [PATCH 04/11] Simplify process --- deploy_application.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/deploy_application.yml b/deploy_application.yml index 9742336..ac79e99 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -4,7 +4,7 @@ become: false vars: artifact_version: 0.0.2 - artifact_job: 10 + artifact_job: 11 artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/10/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }} tasks: @@ -14,23 +14,12 @@ dest: /tmp/BABFrontend.zip mode: '0644' - - name: Unzip file to temp directory + - name: Unzip file to web dir ansible.builtin.unarchive: src: /tmp/BABFrontend.zip - dest: /tmp + dest: /usr/share/nginx/html/ remote_src: true - - name: Extract tgz file to nginx directory - ansible.builtin.unarchive: - src: /tmp/build-{{ artifact_version }}.tar.gz - dest: /usr/share/nginx/html - remote_src: true - - - name: Cleanup temp file - ansible.builtin.file: - path: /tmp/build-artifact-{{ artifact_version }}.tar.gz - state: absent - - name: Clean up artifact download ansible.builtin.file: path: /tmp/BABFrontend.zip -- 2.49.1 From e651d2c21f1eb19f1882858186ed15de8e80a7a6 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:03:22 -0500 Subject: [PATCH 05/11] FIx URL --- deploy_application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index ac79e99..145d3ff 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -5,7 +5,7 @@ vars: artifact_version: 0.0.2 artifact_job: 11 - artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/10/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }} + artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/10/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }}.zip tasks: - name: Download zip file from url -- 2.49.1 From 57f65f81c9ef9e31fbb31cb439e7dcc20ad02054 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:04:39 -0500 Subject: [PATCH 06/11] Fix artifact URL --- deploy_application.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy_application.yml b/deploy_application.yml index 145d3ff..6eb50eb 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -5,8 +5,7 @@ vars: artifact_version: 0.0.2 artifact_job: 11 - artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/10/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }}.zip - + artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/{{ artifact_job }}/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }}.zip tasks: - name: Download zip file from url ansible.builtin.get_url: -- 2.49.1 From 6dca08d9d8f20e93008f0d72bb80371cb7cb2258 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:05:53 -0500 Subject: [PATCH 07/11] Eighth times a charm... --- deploy_application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index 6eb50eb..b96e158 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -5,7 +5,7 @@ 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 }}.zip + artifact_url: https://gitea.toal.ca/oys/bab-app/actions/runs/{{ artifact_job }}/artifacts/build-artifact-{{ artifact_version }}.{{ artifact_job }} tasks: - name: Download zip file from url ansible.builtin.get_url: -- 2.49.1 From a6dcf660b6ecb10e4d6ce804e485f9181002c985 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:33:03 -0500 Subject: [PATCH 08/11] Temporary workaround --- deploy_application.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/deploy_application.yml b/deploy_application.yml index b96e158..13cd8ee 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -13,11 +13,9 @@ dest: /tmp/BABFrontend.zip mode: '0644' + # Temporary until this drops: https://github.com/ansible/ansible/issues/81092 - name: Unzip file to web dir - ansible.builtin.unarchive: - src: /tmp/BABFrontend.zip - dest: /usr/share/nginx/html/ - remote_src: true + ansible.builtin.command: unzip /tmp/BABFrontend.zip -d /usr/share/nginx/html/ - name: Clean up artifact download ansible.builtin.file: -- 2.49.1 From e0732bb8bd0491d9e41fecbecad40065f940fe1d Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:46:06 -0500 Subject: [PATCH 09/11] Force overwrite --- deploy_application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index 13cd8ee..2c07c20 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -15,7 +15,7 @@ # Temporary until this drops: https://github.com/ansible/ansible/issues/81092 - name: Unzip file to web dir - ansible.builtin.command: unzip /tmp/BABFrontend.zip -d /usr/share/nginx/html/ + ansible.builtin.command: unzip /tmp/BABFrontend.zip -o -d /usr/share/nginx/html/ - name: Clean up artifact download ansible.builtin.file: -- 2.49.1 From 39f379ae1e04842b857d0b467babf0a780ad75b7 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 14:47:35 -0500 Subject: [PATCH 10/11] fix order --- deploy_application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy_application.yml b/deploy_application.yml index 2c07c20..dc31535 100644 --- a/deploy_application.yml +++ b/deploy_application.yml @@ -15,7 +15,7 @@ # Temporary until this drops: https://github.com/ansible/ansible/issues/81092 - name: Unzip file to web dir - ansible.builtin.command: unzip /tmp/BABFrontend.zip -o -d /usr/share/nginx/html/ + ansible.builtin.command: unzip -o /tmp/BABFrontend.zip -d /usr/share/nginx/html/ - name: Clean up artifact download ansible.builtin.file: -- 2.49.1 From d3e99ef12bc993d0b507a2a2f406773f0f85b397 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Wed, 20 Dec 2023 17:50:56 -0500 Subject: [PATCH 11/11] Rearrange playbooks. Add EDA --- .../configure_act_runner.yml | 0 .../deploy_application.yml | 0 .../install_appwrite.yml | 0 install_nginx.yml => playbooks/install_nginx.yml | 0 .../provision_users.yml | 0 rulebooks/gitea_webhook.yml | 14 ++++++++++++++ 6 files changed, 14 insertions(+) rename configure_act_runner.yml => playbooks/configure_act_runner.yml (100%) rename deploy_application.yml => playbooks/deploy_application.yml (100%) rename install_appwrite.yml => playbooks/install_appwrite.yml (100%) rename install_nginx.yml => playbooks/install_nginx.yml (100%) rename provision_users.yml => playbooks/provision_users.yml (100%) create mode 100644 rulebooks/gitea_webhook.yml diff --git a/configure_act_runner.yml b/playbooks/configure_act_runner.yml similarity index 100% rename from configure_act_runner.yml rename to playbooks/configure_act_runner.yml diff --git a/deploy_application.yml b/playbooks/deploy_application.yml similarity index 100% rename from deploy_application.yml rename to playbooks/deploy_application.yml diff --git a/install_appwrite.yml b/playbooks/install_appwrite.yml similarity index 100% rename from install_appwrite.yml rename to playbooks/install_appwrite.yml diff --git a/install_nginx.yml b/playbooks/install_nginx.yml similarity index 100% rename from install_nginx.yml rename to playbooks/install_nginx.yml diff --git a/provision_users.yml b/playbooks/provision_users.yml similarity index 100% rename from provision_users.yml rename to playbooks/provision_users.yml diff --git a/rulebooks/gitea_webhook.yml b/rulebooks/gitea_webhook.yml new file mode 100644 index 0000000..0eee119 --- /dev/null +++ b/rulebooks/gitea_webhook.yml @@ -0,0 +1,14 @@ +--- +- name: Listen for Gitea Webhooks + hosts: all + sources: + - name: Ansible webhook listener + ansible.eda.webhook: + port: 5000 + host: 0.0.0.0 + + rules: + - name: Show payload + condition: 1 == 1 + action: + debug: -- 2.49.1