Allow specifying become-primary during deploys

This commit is contained in:
Joshua Boniface 2024-08-19 17:44:13 -04:00
parent 9f47da6777
commit 9a435fe2ae
1 changed files with 12 additions and 0 deletions

View File

@ -13,6 +13,7 @@ else
fi
KEEP_ARTIFACTS=""
PRIMARY_NODE=""
if [[ -n ${1} ]]; then
for arg in ${@}; do
case ${arg} in
@ -20,12 +21,19 @@ if [[ -n ${1} ]]; then
KEEP_ARTIFACTS="y"
shift
;;
-p=*|--become-primary=*)
PRIMARY_NODE=$( awk -F'=' '{ print $NF }' <<<"${arg}" )
shift
;;
esac
done
fi
HOSTS=( ${@} )
echo "Deploying to host(s): ${HOSTS[@]}"
if [[ -n ${PRIMARY_NODE} ]]; then
echo "Will become primary on ${PRIMARY_NODE} after updating it"
fi
# Move to repo root if we're not
pushd $( git rev-parse --show-toplevel ) &>/dev/null
@ -78,6 +86,10 @@ for HOST in ${HOSTS[@]}; do
echo -n "."
done
echo " done."
if [[ -n ${PRIMARY_NODE} && ${PRIMARY_NODE} == ${HOST} ]]; then
echo -n ">>> "
ssh $HOST pvc -q node primary
fi
done
popd &>/dev/null