diff --git a/roles/deploy_code/tasks/cleanup.yml b/roles/deploy_code/tasks/cleanup.yml index 5ed7b4ad..c722b049 100644 --- a/roles/deploy_code/tasks/cleanup.yml +++ b/roles/deploy_code/tasks/cleanup.yml @@ -104,55 +104,45 @@ - deploy_code.mount_sync | length > 1 - deploy_code.mount_type == "squashfs" -#- name: Check if we have a mount already. -# ansible.builtin.shell: -# cmd: "mount | grep {{ deploy_base_path }}" -# ignore_errors: true -# register: _mount_check -# when: -# - deploy_code.mount_sync is defined -# - deploy_code.mount_sync | length > 1 -# - deploy_code.mount_type == "squashfs" +- name: Check if we have a mount already. + ansible.builtin.shell: + cmd: "mount | grep {{ deploy_base_path }}" + ignore_errors: true + register: _mount_check + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type == "squashfs" - name: Unmount existing SquashFS image. - ansible.posix.mount: - path: "{{ deploy_base_path }}" - state: unmounted + ansible.builtin.command: + cmd: "umount -l {{ deploy_base_path }}" 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 is succeeded - -#- 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 is succeeded -# - deploy_code.services | length > 0 + - _mount_check is succeeded + +- 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 + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type == "squashfs" + - _mount_check is succeeded + - deploy_code.services | length > 0 - name: Mount new SquashFS image. - ansible.posix.mount: - #cmd: "mount {{ build_base_path }}/deploy.sqsh {{ deploy_base_path }} -t squashfs -o loop" - src: "{{ build_base_path }}/deploy.sqsh" - path: "{{ deploy_base_path }}" - state: mounted - opts: loop - fstype: squashfs - boot: false + ansible.builtin.command: + cmd: "mount {{ build_base_path }}/deploy.sqsh {{ deploy_base_path }} -t squashfs -o loop" become: true - become_user: "{{ deploy_user }}" when: - deploy_code.mount_sync is defined - deploy_code.mount_sync | length > 1