tripleo-upgrade/templates/overcloud_update_run.sh.j2
Bogdan Dobrelya 9ceca92d20 Fix --yes evaluation from the help CLI
Sometimes, CLI may return error earlier than grep catches up
its query results. With bash pipefail set, this ends up with grep --yes
omitted and the wrong command executed (without --yes).

Set pipefail only after the --yes argument evaluated by grep.

Change-Id: I22a998e0cf3b04ef51a51478fc6576324a931dcb
Co-Authored-By: Sergii Golovatouk <sgolovat@redhat.com>
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
2020-07-16 17:16:21 +02:00

40 lines
910 B
Django/Jinja

#!/bin/env bash
#
# Run minor update on overcloud nodes
#
set -eu
RUN_ANSWER=""
if openstack overcloud update run --help | grep -qe "--yes"; then
RUN_ANSWER="--yes"
fi
set -o pipefail
source {{ undercloud_rc }}
{% if overcloud_update_multibooks|bool %}
{%- for playbook in overcloud_update_playbooks -%}
echo "Running minor update {{ playbook }} playbook for {{ item }} role"
openstack overcloud update run ${RUN_ANSWER} \
--stack {{ overcloud_stack_name }} \
{% if tripleo_upgrade_debug|bool %}
--debug \
{% endif %}
--limit {{ item }} --playbook {{ playbook }} 2>&1
{%- endfor -%}
{% else %}
echo "Running minor update all playbooks for {{ item }} role"
openstack overcloud update run ${RUN_ANSWER} \
--stack {{ overcloud_stack_name }} \
{% if tripleo_upgrade_debug|bool %}
--debug \
{% endif %}
--limit {{ item }} --playbook all 2>&1
{% endif %}