From ef778539e8ade6de32b5d526a3bd900c9b60c248 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Wed, 5 Sep 2018 14:44:28 -0400 Subject: [PATCH] Fix check mode for server deployments The task to remove the deployment status file from a previous failed attempt was failing during check mode since the registered variables it relies upon are not set. This patch updates the task to not run during check mode. Change-Id: I11b33f8fae6a7f1f96ce810495c92ad4e33ef66c Closes-Bug: #1790928 --- ...k-mode-server-deployment-098bcae9e0227c57.yaml | 5 +++++ tripleo_common/templates/deployments.yaml | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/fix-check-mode-server-deployment-098bcae9e0227c57.yaml 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