diff --git a/roles/deploy_code/defaults/main.yml b/roles/deploy_code/defaults/main.yml index d616bf08..bff3cd01 100644 --- a/roles/deploy_code/defaults/main.yml +++ b/roles/deploy_code/defaults/main.yml @@ -15,8 +15,10 @@ deploy_code: templates: [] # Number of builds to keep. Note this is independant of databases/dump. keep: 10 - # Wether to sync the local deploy base to a shared destination, after successful build. + # Whether to sync the local deploy base to a shared destination, after successful build. mount_sync: "" + # Type of file to use for sync - 'squashfs' or 'tarball' + mount_type: "" # mount_sync: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/deploy" # Path that you want to make sure has 755 permissions. Make sure to include the webroot WITHOUT the slash. perms_fix_path: "" diff --git a/roles/deploy_code/tasks/cleanup.yml b/roles/deploy_code/tasks/cleanup.yml index 03530f22..e9e58146 100644 --- a/roles/deploy_code/tasks/cleanup.yml +++ b/roles/deploy_code/tasks/cleanup.yml @@ -26,6 +26,18 @@ when: - deploy_code.mount_sync is defined - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type is defined + - deploy_code.mount_type == "tarball" + run_once: true + +- name: Create a SquashFS image of the deployed codebases. + ansible.builtin.command: + cmd: "mksquashfs {{ deploy_base_path }} /tmp/{{ project_name }}_{{ build_type }}.sqsh" + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type is defined + - deploy_code.mount_type == "squashfs" run_once: true - name: Create destination folder. @@ -38,12 +50,24 @@ - deploy_code.mount_sync | length > 1 run_once: true -- name: Move to final destination. +- name: Move tar file to final destination. ansible.builtin.command: cmd: "mv /tmp/{{ project_name }}_{{ build_type }}.tar {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.tar" when: - deploy_code.mount_sync is defined - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type is defined + - deploy_code.mount_type == "tarball" + run_once: true + +- name: Move SquashFS image to final destination. + ansible.builtin.command: + cmd: "mv /tmp/{{ project_name }}_{{ build_type }}.sqsh {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh" + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type is defined + - deploy_code.mount_type == "squashfs" run_once: true - name: Trigger an infrastructure rebuild.