Avere/azure-pipelines.yml

225 строки
8.8 KiB
YAML

# Copyright (C) Microsoft Corporation. All rights reserved.
# https://aka.ms/yaml
trigger: none
parameters:
- name: region
displayName: "Region to run pipeline"
type: string
default: "eastus"
values:
- australiaeast
- australiasoutheast
- brazilsouth
- canadacentral
- canadaeast
- centralus
- eastasia
- eastus
- eastus2
- francecentral
- japaneast
- japanwest
- koreacentral
- koreasouth
- northeurope
- northcentralus
- southcentralus
- southeastasia
- southeastindia
- uksouth
- ukwest
- westus
- westus2
- westus3
- westeurope
- westindia
variables:
VFXT_DEPLOY_LOCATION: '${{ parameters.region}}'
jobs:
- job: ARM_Template_Test
timeoutInMinutes: 90
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
architecture: 'x64'
- bash: |
export PATH=$PATH:${BUILD_SOURCESDIRECTORY}/test/utils
echo "##[group]Dump environment variables"
env | sort
echo "##[endgroup]"
pip install --upgrade pip setuptools wheel
check_rc.sh $? "Upgrade Python pip" || exit 0
pip install -r test/requirements.txt
check_rc.sh $? "Install Python requirements" || exit 0
displayName: 'SETUP: Install Python dependencies'
condition: succeeded()
- bash: |
export PATH=$PATH:${BUILD_SOURCESDIRECTORY}/test/utils
echo "##[group]Login to Azure CLI"
az login --service-principal \
--username ${AZURE_CLIENT_ID} \
--password ${AZURE_CLIENT_SECRET} \
--tenant ${AZURE_TENANT_ID}
check_rc.sh $? "Login to Azure CLI" || exit 0
az account set --subscription ${AZURE_SUBSCRIPTION_ID}
check_rc.sh $? "Set default Azure subscription" || exit 0
echo "##[endgroup]"
# Set various variables, deferring to user-specified values.
export _timestamp=$(date -u '+%m%dx%H%M%S')
export _RESOURCE_GROUP=${RESOURCE_GROUP:-arm-vfxt-${_timestamp}}
export _REGION=${VFXT_DEPLOY_LOCATION:-eastus}
export _NSG=${NSG:-nsg-${_timestamp}}
export _VNET_RG=${VNET_RG:-${_RESOURCE_GROUP}-vnet}
export _VNET=${VNET:-vnet-${_timestamp}}
export _VNET_ADDR_PREFIX=${VNET_ADDR_PREFIX:-'10.0.0.0/16'}
export _SUBNET=${SUBNET:-subnet-${_timestamp}}
export _CLUSTER=${CLUSTER:-vfxt-cluster-${_timestamp}}
export _CONTROLLER=${CONTROLLER:-controller-${_timestamp}}
export _CONTROLLER_USERID=${CONTROLLER_USERID:-azureuser}
export _STORAGE_ACCOUNT=${STORAGE_ACCOUNT:-vfxt$(uuidgen | tr A-Z a-z | sed 's/-//g' | cut -c -20)}
# Generate an SSH key for use on the controller.
ssh-keygen -b 1024 -t rsa -f temp_ssh_key -q -N "" -C ""
check_rc.sh $? "Generate SSH key" || exit 0
export _SSH_PUB_KEY=${SSH_PUB_KEY:-$(head -1 temp_ssh_key.pub)}
echo "##[group]Dump environment variables"
env | sort
echo "##[endgroup]"
# Task variables available to subsequent tasks as envars.
echo "##vso[task.setvariable variable=_RESOURCE_GROUP]${_RESOURCE_GROUP}"
echo "##vso[task.setvariable variable=_VNET_RG]${_VNET_RG}"
# Add extra arguments when specified at queue time.
EXTRA_ARGS=''
[[ -n "${VFXT_CONTROLLER_IMG_REF_ID}" ]] && EXTRA_ARGS+=" -p controllerImageReferenceId=${VFXT_CONTROLLER_IMG_REF_ID}"
[[ -n "${VFXT_NODE_IMAGE_REF_ID}" ]] && EXTRA_ARGS+=" -p nodeImageId=${VFXT_NODE_IMAGE_REF_ID}"
[[ -n "${VFXT_CONTROLLER_MKT_OFFER}" ]] && EXTRA_ARGS+=" -p controllerMarketplaceOffer=${VFXT_CONTROLLER_MKT_OFFER}"
[[ -n "${VFXT_CONTROLLER_MKT_VERSION}" ]] && EXTRA_ARGS+=" -p controllerMarketplaceVersion=${VFXT_CONTROLLER_MKT_VERSION}"
# If the vFXT's RG is different from the vnet's RG, then we assume that
# the vnet and associated resources already exist.
[[ "${_RESOURCE_GROUP}" != "${_VNET_RG}" ]] && EXTRA_ARGS+=" -p createVirtualNetwork=false"
echo "##[group]Create resource group(s) in ${_REGION}"
az group create --location ${_REGION} --name ${_RESOURCE_GROUP}
check_rc.sh $? "Create resource group (${_RESOURCE_GROUP}) in ${_REGION}" || exit 0
if [[ "${_RESOURCE_GROUP}" != "${_VNET_RG}" ]]; then
az group create --location ${_REGION} --name ${_VNET_RG}
check_rc.sh $? "Create resource group (${_VNET_RG}) in ${_REGION}" || exit 0
fi
echo "##[endgroup]"
if [[ "${_RESOURCE_GROUP}" != "${_VNET_RG}" ]]; then
echo "##[group]Create network resources in ${_VNET_RG}"
az network nsg create \
--resource-group ${_VNET_RG} \
--location ${_REGION} \
--name ${_NSG}
check_rc.sh $? "Create network security group (${_NSG})" || exit 0
az network vnet create \
--resource-group ${_VNET_RG} \
--location ${_REGION} \
--name ${_VNET} \
--address-prefixes ${_VNET_ADDR_PREFIX} \
--subnet-name ${_SUBNET} \
--network-security-group ${_NSG}
check_rc.sh $? "Create vnet (${_VNET}) and subnet (${_SUBNET}) in ${_VNET_RG}" || exit 0
az network vnet subnet update \
--resource-group ${_VNET_RG} \
--vnet-name ${_VNET} \
--name ${_SUBNET} \
--service-endpoints Microsoft.Storage
check_rc.sh $? "Add Microsoft.Storage to subnet ${_SUBNET} in ${_VNET}" || exit 0
echo "##[endgroup]"
fi
echo "##[group]Deploy vFXT (${_CLUSTER}) to ${_RESOURCE_GROUP} in ${_REGION}"
az deployment group create \
--template-file ${BUILD_SOURCESDIRECTORY}/src/vfxt/azuredeploy-auto.json \
--resource-group ${_RESOURCE_GROUP} \
--parameters "{ \
'location': { 'value': '${_REGION}' }, \
'virtualNetworkResourceGroup': { 'value': '${_VNET_RG}' }, \
'virtualNetworkName': { 'value': '${_VNET}' }, \
'virtualNetworkSubnetName': { 'value': '${_SUBNET}' }, \
'avereBackedStorageAccountName': { 'value': '${_STORAGE_ACCOUNT}' }, \
'controllerName': { 'value': '${_CONTROLLER}' }, \
'controllerAdminUsername': { 'value': '${_CONTROLLER_USERID}' }, \
'avereClusterName': { 'value': '${_CLUSTER}' }, \
'controllerSSHKeyData': { 'value': '${_SSH_PUB_KEY}' }, \
'adminPassword': { 'value': '${AVERE_ADMIN_PW}' } \
}" ${EXTRA_ARGS}
check_rc.sh $? "Deploy vFXT (${_CLUSTER}) to ${_RESOURCE_GROUP} in ${_REGION}" || exit 0
echo "##[endgroup]"
displayName: 'TEST: Deploy vFXT cluster'
condition: succeeded()
env:
AVERE_ADMIN_PW: $(AVERE-ADMIN-PW)
AVERE_CONTROLLER_PW: $(AVERE-CONTROLLER-PW)
AZURE_TENANT_ID: $(AZURE-TENANT-ID)
AZURE_CLIENT_ID: $(AZURE-CLIENT-ID)
AZURE_CLIENT_SECRET: $(AZURE-CLIENT-SECRET)
AZURE_SUBSCRIPTION_ID: $(AZURE-SUBSCRIPTION-ID)
- bash: |
export PATH=$PATH:${BUILD_SOURCESDIRECTORY}/test/utils
_ipcfgs_file=/tmp/ipcfgs.lst
az network public-ip list \
--resource-group ${_RESOURCE_GROUP} \
--output tsv --query '[].ipConfiguration.id' |& tee ${_ipcfgs_file}
check_rc.sh ${PIPESTATUS[0]} "List IP configs with a public IP address" || exit 0
az network nic ip-config update \
--public-ip-address "" \
--ids @- < ${_ipcfgs_file}
check_rc.sh ${PIPESTATUS[0]} "Disassociate public IP addresses from all IP configs" || exit 0
_pubips_file=/tmp/pubips.lst
az network public-ip list \
--resource-group ${_RESOURCE_GROUP} \
--output tsv --query '[].id' |& tee ${_pubips_file}
check_rc.sh ${PIPESTATUS[0]} "List all public IP address resources" || exit 0
az network public-ip delete --ids @- < ${_pubips_file}
check_rc.sh ${PIPESTATUS[0]} "Delete all public IP address resources" || exit 0
displayName: 'CLEAN UP: Delete public IP resource(s)'
condition: always()
- bash: |
export PATH=$PATH:${BUILD_SOURCESDIRECTORY}/test/utils
echo "##[group]Dump environment variables"
env | sort
echo "##[endgroup]"
az group delete --yes --name ${_RESOURCE_GROUP}
check_rc.sh $? "Delete resource group (${_RESOURCE_GROUP})"
if [[ "${_RESOURCE_GROUP}" != "${_VNET_RG}" ]]; then
az group delete --yes --name ${_VNET_RG}
check_rc.sh $? "Delete resource group (${_VNET_RG})"
fi
displayName: 'CLEAN UP: Delete resource group(s)'
condition: and(always(), ne(variables['SKIP_RG_CLEANUP'], 'true'))