diff --git a/roles/deploy_code/tasks/cleanup.yml b/roles/deploy_code/tasks/cleanup.yml index 73834d91..8dd737b9 100644 --- a/roles/deploy_code/tasks/cleanup.yml +++ b/roles/deploy_code/tasks/cleanup.yml @@ -141,25 +141,21 @@ - deploy_code.mount_sync | length > 1 - deploy_code.mount_type == "squashfs" -- name: Check if we have a mount already. - ansible.builtin.shell: - cmd: "set -o pipefail && mount | grep {{ deploy_base_path }}" - args: - executable: /bin/bash - failed_when: false - register: _deploy_code_mount_check - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" - - name: Unmount and remount squashfs images. when: - deploy_code.mount_sync is defined - deploy_code.mount_sync | length > 1 - deploy_code.mount_type == "squashfs" - - _deploy_code_mount_check.rc == 0 + throttle: 1 # execute one machine at a time block: + - name: Check if we have a mount already. + ansible.builtin.shell: + cmd: "set -o pipefail && mount | grep {{ deploy_base_path }}" + args: + executable: /bin/bash + failed_when: false + register: _deploy_code_mount_check + - name: Reload any services that might be keeping the loop device busy. ansible.builtin.service: name: "{{ www_service }}" @@ -169,6 +165,7 @@ loop_var: www_service become: true when: + - _deploy_code_mount_check.rc == 0 - deploy_code.service_action == "reload" - deploy_code.services | length > 0 @@ -181,6 +178,7 @@ loop_var: www_service become: true when: + - _deploy_code_mount_check.rc == 0 - deploy_code.service_action == "stop" - deploy_code.services | length > 0 @@ -188,6 +186,8 @@ ansible.builtin.command: cmd: "umount {{ deploy_base_path }}" become: true + when: + - _deploy_code_mount_check.rc == 0 - name: Mount new SquashFS image. ansible.builtin.command: @@ -203,6 +203,7 @@ loop_var: www_service become: true when: + - _deploy_code_mount_check.rc == 0 - deploy_code.service_action == "stop" - deploy_code.services | length > 0