diff --git a/substrate/.gitlab-ci.yml b/substrate/.gitlab-ci.yml index bcedb0c6e1..ff4172aa5e 100644 --- a/substrate/.gitlab-ci.yml +++ b/substrate/.gitlab-ci.yml @@ -10,7 +10,8 @@ stages: - test - build - publish - - deploy + - kubernetes + - flaming-fir image: parity/rust-builder:latest @@ -264,7 +265,7 @@ publish-s3-doc: --human-readable --summarize .deploy-template: &deploy - stage: deploy + stage: kubernetes when: manual retry: 1 image: parity/kubetools:latest @@ -332,7 +333,7 @@ deploy-ue1-tag: name: parity-prod-ue1 .validator-deploy: &validator-deploy - stage: publish + stage: flaming-fir dependencies: - build-linux-release image: parity/azure-ansible:v1 @@ -344,10 +345,16 @@ deploy-ue1-tag: validator1: <<: *validator-deploy script: - - ansible-playbook -i scripts/ansible/inventory.ini -u gitlab scripts/ansible/alexander.yml -l validator1 - + - ./scripts/flamingfir-deploy.sh flamingfir-validator1 validator2: <<: *validator-deploy script: - - ansible-playbook -i scripts/ansible/inventory.ini -u gitlab scripts/ansible/alexander.yml -l validator2 - + - ./scripts/flamingfir-deploy.sh flamingfir-validator2 +validator3: + <<: *validator-deploy + script: + - ./scripts/flamingfir-deploy.sh flamingfir-validator3 +validator4: + <<: *validator-deploy + script: + - ./scripts/flamingfir-deploy.sh flamingfir-validator4 diff --git a/substrate/scripts/flamingfir-deploy.sh b/substrate/scripts/flamingfir-deploy.sh new file mode 100755 index 0000000000..ffd3cab9d8 --- /dev/null +++ b/substrate/scripts/flamingfir-deploy.sh @@ -0,0 +1,35 @@ +#!/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 "==================================="