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