diff --git a/releasenotes/notes/fix-check-mode-server-deployment-098bcae9e0227c57.yaml b/releasenotes/notes/fix-check-mode-server-deployment-098bcae9e0227c57.yaml new file mode 100644 index 000000000..af99db24e --- /dev/null +++ b/releasenotes/notes/fix-check-mode-server-deployment-098bcae9e0227c57.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Previously, running ansible-playbook with --check would cause a failure + during the individual server deployments when checking the result of a + previous attempt. diff --git a/tripleo_common/templates/deployments.yaml b/tripleo_common/templates/deployments.yaml index c3fd0109e..99d54b919 100644 --- a/tripleo_common/templates/deployments.yaml +++ b/tripleo_common/templates/deployments.yaml @@ -18,6 +18,7 @@ exit $(jq .deploy_status_code /var/lib/heat-config/deployed/{{ deployment_uuid }}.notify.json) register: previous_deployment_result ignore_errors: true + failed_when: false when: deployed_file_stat.stat.exists - name: "Remove deployed file for {{ item }} when previous deployment failed" @@ -25,7 +26,10 @@ path: /var/lib/heat-config/deployed/{{ deployment_uuid }}.json state: absent become: true - when: deployed_file_stat.stat.exists and previous_deployment_result.rc != 0 + when: + - not ansible_check_mode + - deployed_file_stat.stat.exists + - previous_deployment_result.rc != 0 - name: "Force remove deployed file for {{ item }}" file: @@ -54,12 +58,11 @@ failed_when: deployment_result.rc != 0 when: not ansible_check_mode -- name: "Check-mode for Run deployment {{ item }}" - shell: | - [[ -e /var/lib/heat-config/deployed/{{ deployment_uuid }}.json ]] +- name: "Check-mode for Run deployment {{ item }} (changed status indicates deployment would run)" + stat: + path: /var/lib/heat-config/deployed/{{ deployment_uuid }}.json become: true register: deploy_exists - changed_when: deploy_exists.rc != 0 + changed_when: not deploy_exists.stat.exists when: ansible_check_mode - check_mode: no ignore_errors: yes