Merge "Fix check mode for server deployments"

This commit is contained in:
Zuul
2018-10-02 18:52:02 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 6 deletions

View File

@@ -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.

View File

@@ -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