Files
pezkuwi-subxt/substrate/scripts/flamingfir-deploy.sh
T
ddorgan a827869dfb Flaming fir deployment scripts (#2599)
* Initial commit of flaming fir deployment scripts

* Debug

* Fix formatting

* Correct wget syntax

* Use 8 char commit id

* 9 chars

* Use the longer CI_BUILD_REF ref to slice from

* Fix backtick error with flaming fir deploy script

* Use the correct commit id length

* Split out validator deploments

* Fix syntax, missing :

* Pass hostname as TARGET_HOST per validator

* Correct syntax

* Uncomment wget

* Switch deploy -> kubernetes

* Use full group name

* Check awx log

* Fix if syntax and ignore failed

* Use correct JOB_ID and fix if syntax

* Use correct variable

* Print ansible awx log and status

* Make awx status clearer

* make variable names consistent

* Do 15 second checkups on the job

* Remove extra echo

* Use artifacts/VERSION instead of gitlab variables

* Use all of the VERSION info
2019-05-18 21:50:38 +01:00

36 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
RETRY_COUNT=10
RETRY_ATTEMPT=0
SLEEP_TIME=15
TARGET_HOST="$1"
COMMIT=$(cat artifacts/VERSION)
DOWNLOAD_URL="https://releases.parity.io/substrate/x86_64-debian:stretch/${COMMIT}/substrate"
POST_DATA='{"extra_vars":{"artifact_path":"'${DOWNLOAD_URL}'","target_host":"'${TARGET_HOST}'"}}'
JOB_ID=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" --header "Content-type: application/json" --post-data "${POST_DATA}" https://ansible-awx.parity.io/api/v2/job_templates/32/launch/ | jq .job)
echo "Launched job: $JOB_ID"
while [ ${RETRY_ATTEMPT} -le ${RETRY_COUNT} ] ; do
export RETRY_RESULT=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/ | jq .status)
RETRY_ATTEMPT=$(( $RETRY_ATTEMPT +1 ))
sleep $SLEEP_TIME
if [ $(echo $RETRY_RESULT | egrep -e successful -e failed) ] ; then
break
fi
done
AWX_OUTPUT=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/stdout?format=txt_download)
echo "AWX job log:"
echo "${AWX_OUTPUT}"
JOB_STATUS=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/ | jq .status )
echo "==================================="
echo -e "Ansible AWX Remote Job: ${JOB_ID} \x1B[31mStatus: ${JOB_STATUS}\x1B[0m"
echo "==================================="