---

# The purpose of writing the overcloud status out to a json file is to
# allow ansible to capture the status, and then execute required steps
# after the deployment fails e.g. inventory
# After the deployment fails and inventory is collected the playbook then
# checks the status via the json file and passes or fails at the appropriate
# time.
- name: write out overcloud status to a file on the localhost
  shell: >
    echo '{ "overcloud_deploy_result": "failed" }' > "{{ local_working_dir }}/overcloud_deployment_result.json"
  delegate_to: localhost
  when: deploy_script_result.rc != 0

- name: write out overcloud status to a file on the localhost
  shell: >
    echo '{ "overcloud_deploy_result": "passed" }' > "{{ local_working_dir }}/overcloud_deployment_result.json"
  delegate_to: localhost
  when: deploy_script_result.rc == 0

- name: import deployment status from file
  include_vars: "{{ local_working_dir }}/overcloud_deployment_result.json"

- name: echo deployment_status
  debug: var=overcloud_deploy_result
