#!/bin/env bash
#
# Setup HEAT's output
#
set -euo pipefail

# FIXME: Remove --validation-errors-nonfatal. In local testing it was
# not necessary but in RDO cloud validations seem to produce errors.
echo "Setting up HEAT's output for minor update"
openstack overcloud update prepare --templates {{ tht_directory }} \
    --stack {{ overcloud_stack_name }} \
    {% if tripleo_upgrade_debug|bool %}
    --debug \
    {% endif %}
    {% if tripleo_upgrade_validations_non_fatal|bool %}
    --validation-errors-nonfatal \
    {% endif %}
    {% if initial_env_file is defined and initial_env_file.stdout_lines|length > 0 %}
    {% for _env in initial_env_file.stdout_lines %}
        -e {{ _env }} \
    {% endfor %}
    {% endif %}
    --roles-file {{ roles_data }} \
    --container-registry-file {{ working_dir }}/{{ container_registry_file }} 2>&1
