-
Notifications
You must be signed in to change notification settings - Fork 32
/
azure-pipelines.yml
225 lines (192 loc) · 8.78 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# 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'))