diff --git a/roles/deploy_code/defaults/main.yml b/roles/deploy_code/defaults/main.yml index c0e29363..2c496e6b 100644 --- a/roles/deploy_code/defaults/main.yml +++ b/roles/deploy_code/defaults/main.yml @@ -17,13 +17,18 @@ deploy_code: keep: 10 # Whether to sync the local deploy base to a shared destination, after successful build. mount_sync: "" + # mount_sync: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/deploy" # Type of file to use for sync - 'squashfs' or 'tarball' # @see the _init role for SquashFS build dir paths mount_type: "tarball" - # 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: "" # perms_fix_path: "www/sites/default" + # List of services to reload to free the loop device for 'squashfs' builds, post lazy umount. + # @see the squashfs role in ce-provision where special permissions for deploy user to manipulate services get granted. + services: [] + # services: + # - php8.0-fpm # Trigger an API call to rebuild infra after a deploy, e.g. if you need to repack an AMI. rebuild_infra: false # Details of API call to trigger. See api_call role. diff --git a/roles/deploy_code/tasks/cleanup.yml b/roles/deploy_code/tasks/cleanup.yml index e7146438..e2b1cc48 100644 --- a/roles/deploy_code/tasks/cleanup.yml +++ b/roles/deploy_code/tasks/cleanup.yml @@ -114,9 +114,9 @@ - deploy_code.mount_sync | length > 1 - deploy_code.mount_type == "squashfs" -- name: Remount existing SquashFS image. +- name: Unmount existing SquashFS image. ansible.builtin.command: - cmd: "mount {{ build_base_path }}/deploy.sqsh {{ deploy_base_path }} -t squashfs -o remount" + cmd: "umount -l {{ deploy_base_path }}" become: true become_user: "{{ deploy_user }}" when: @@ -125,6 +125,22 @@ - deploy_code.mount_type == "squashfs" - _mount_check|success +- name: Reload any services that might be keeping the loop device busy. + ansible.builtin.service: + name: "{{ www_service }}" + state: reloaded + with_items: "{{ deploy_code.services }}" + loop_control: + loop_var: www_service + become: true + become_user: "{{ deploy_user }}" + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type == "squashfs" + - _mount_check|success + - deploy_code.services | length > 0 + - name: Mount new SquashFS image. ansible.builtin.command: cmd: "mount {{ build_base_path }}/deploy.sqsh {{ deploy_base_path }} -t squashfs -o loop" @@ -134,7 +150,6 @@ - deploy_code.mount_sync is defined - deploy_code.mount_sync | length > 1 - deploy_code.mount_type == "squashfs" - - _mount_check|failed - name: Trigger an infrastructure rebuild. ansible.builtin.include_role: