-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
326 lines (293 loc) · 18 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
trigger:
branches:
include:
- master
paths:
exclude:
- 'README.md'
- 'images/*'
stages:
- stage: test_and_build
jobs:
- job: Pester_Tests
variables:
- group: test - network
displayName: Pester Tests
pool:
name: Hosted Windows 2019 with VS2019
demands: azureps
steps:
- powershell: |
$FeedName = 'PSGallery'
Install-PackageProvider Nuget -Scope CurrentUser -Force
Install-module PSScriptAnalyzer -force -Scope CurrentUser -Repository $FeedName
Install-module PSPesterTest -force -Scope CurrentUser -Repository $FeedName
displayName: 'Install required PowerShell modules'
- task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
displayName: 'Pester Test Runner - Hub Network Template'
inputs:
scriptFolder: '@{Path=''$(System.DefaultWorkingDirectory)\tests\ARMTemplate\Test.ARMTemplate.ps1''; Parameters=@{TemplatePath =''$(System.DefaultWorkingDirectory)\templates\\hub\\hub.network.azuredeploy.json''; parameters =$(hubParameters); variables = $(hubVariables); resources = $(hubResources)}}'
resultsFile: '$(System.DefaultWorkingDirectory)\TEST-Hub-Network.xml'
- task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
displayName: 'Pester Test Runner - Spoke Network Template'
inputs:
scriptFolder: '@{Path=''$(System.DefaultWorkingDirectory)\tests\ARMTemplate\Test.ARMTemplate.ps1''; Parameters=@{TemplatePath =''$(System.DefaultWorkingDirectory)\templates\\spoke\\spoke.network.azuredeploy.json''; parameters =$(SpokeParameters); variables = $(SpokeVariables); resources = $(SpokeResources)}}'
resultsFile: '$(System.DefaultWorkingDirectory)\TEST-Spoke-Network.xml'
- task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
displayName: 'Pester Test Runner - VNet Peering Template'
inputs:
scriptFolder: '@{Path=''$(System.DefaultWorkingDirectory)\tests\ARMTemplate\Test.ARMTemplate.ps1''; Parameters=@{TemplatePath =''$(System.DefaultWorkingDirectory)\templates\\vnetPeering\\vnet.peering.azuredeploy.json''; parameters =$(peeringParameters); resources = $(peeringResources)}}'
resultsFile: '$(System.DefaultWorkingDirectory)\TEST-Network-Peering.xml'
- task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
displayName: 'Pester Test Runner - Private DNS Zone Template'
inputs:
scriptFolder: '@{Path=''$(System.DefaultWorkingDirectory)\tests\ARMTemplate\Test.ARMTemplate.ps1''; Parameters=@{TemplatePath =''$(System.DefaultWorkingDirectory)\templates\\private-dns-zone\\private.dns.zone.azuredeploy.json''; parameters =$(dnsZoneParameters); resources = $(dnsZoneResources)}}'
resultsFile: '$(System.DefaultWorkingDirectory)\TEST-Private-DNS-Zone.xml'
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
testResultsFormat: NUnit
- job: ARM_Deployment_Validation
variables:
- group: variables - network
displayName: ARM Deployment Validation
dependsOn: Pester_Tests
pool:
name: Hosted Windows 2019 with VS2019
demands: azureps
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Template Validation - Hub Network Template'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: templates/hub/hub.network.azuredeploy.json
csmParametersFile: templates/hub/hub.network.azuredeploy.parameters.json
overrideParameters: '-hubVnetName $(hubVnetName) -localNetworkAddressPrefixes $(localNetworkAddressPrefixes) -localGatewayIpAddress $(localGatewayIpAddress) -deployVpnGateway $(deployVpnGateway) -IPSecSharedKey $(IPSecSharedKey) -deployAaddsSubnet $(deployAaddsSubnet)'
deploymentMode: Validation
- task: AzureResourceGroupDeployment@2
displayName: 'Template Validation - Spoke Network Template'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0101)'
location: '$(spokeLocation0101)'
csmFile: templates/spoke/spoke.network.azuredeploy.json
csmParametersFile: templates/spoke/spoke.sub1.network1.azuredeploy.parameters.json
deploymentMode: Validation
- job: Publish_Pattern
displayName: Publish Pattern
dependsOn:
- Pester_Tests
- ARM_Deployment_Validation
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- stage: lab_deploy
jobs:
- deployment: lab_deploy
variables:
- group: variables - network
displayName: 'Deploy Network Pattern to Lab environment'
pool:
name: Hosted Windows 2019 with VS2019
demands: azureps
timeoutInMinutes: 120
environment: 'lab'
strategy:
runOnce:
deploy:
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Hub VNet in Management Subscription'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/hub/hub.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/hub/hub.network.azuredeploy.parameters.json'
overrideParameters: '-hubVnetName $(hubVnetName) -localNetworkAddressPrefixes $(localNetworkAddressPrefixes) -localGatewayIpAddress $(localGatewayIpAddress) -deployVpnGateway $(deployVpnGateway) -IPSecSharedKey $(IPSecSharedKey) -deployAaddsSubnet $(deployAaddsSubnet)'
deploymentOutputs: hubVnetOutput
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(hubVnetOutput)'
errorActionPreference: 'stop'
displayName: 'Parse Hub VNet deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Spoke VNet 0101 in Workload Subscription'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0101)'
location: '$(spokeLocation0101)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.sub1.network1.azuredeploy.parameters.json'
deploymentOutputs: spokeVnet101Output
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(spokeVnet101Output)' -variableNameSuffix '101'
errorActionPreference: 'stop'
displayName: 'Parse Spoke VNet 0101 deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Spoke VNet 0102 in Workload Subscription'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0102)'
location: '$(spokeLocation0102)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.sub1.network2.azuredeploy.parameters.json'
deploymentOutputs: spokeVnet102Output
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(spokeVnet102Output)' -variableNameSuffix '102'
errorActionPreference: 'stop'
displayName: 'Parse Spoke VNet 0102 deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Spoke VNet 0103 in Workload Subscription'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0103)'
location: '$(spokeLocation0103)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.sub1.network3.azuredeploy.parameters.json'
deploymentOutputs: spokeVnet103Output
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(spokeVnet103Output)' -variableNameSuffix '103'
errorActionPreference: 'stop'
displayName: 'Parse Spoke VNet 0103 deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Spoke VNet 0201 in Workload Subscription'
inputs:
azureSubscription: 'sub-workload-2'
resourceGroupName: '$(spokeResourceGroup0201)'
location: '$(spokeLocation0201)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.sub2.network1.azuredeploy.parameters.json'
deploymentOutputs: spokeVnet201Output
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(spokeVnet201Output)' -variableNameSuffix '201'
errorActionPreference: 'stop'
displayName: 'Parse Spoke VNet 0201 deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Spoke VNet 0202 in Workload Subscription'
inputs:
azureSubscription: 'sub-workload-2'
resourceGroupName: '$(spokeResourceGroup0202)'
location: '$(spokeLocation0202)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.network.azuredeploy.json'
csmParametersFile: '$(Agent.BuildDirectory)/drop/templates/spoke/spoke.sub2.network2.azuredeploy.parameters.json'
deploymentOutputs: spokeVnet202Output
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: '$(Agent.BuildDirectory)/drop/scripts/parse.arm.outputs.ps1'
arguments: -Output '$(spokeVnet202Output)' -variableNameSuffix '202'
errorActionPreference: 'stop'
displayName: 'Parse Spoke VNet 0202 deployment outputs'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Spoke VNet 0101 to Hub VNet'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0101)'
location: '$(spokeLocation0101)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(spokeVnetName0101) -remoteVnetName $(hubVNetName) -remoteVnetSubscriptionId "$(hubVnetSubId)" -remoteVnetResourceGroup $(hubResourceGroup)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Spoke VNet 0102 to Hub VNet'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0102)'
location: '$(spokeLocation0102)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(spokeVnetName0102) -remoteVnetName $(hubVNetName) -remoteVnetSubscriptionId "$(hubVnetSubId)" -remoteVnetResourceGroup $(hubResourceGroup)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Spoke VNet 0103 to Hub VNet'
inputs:
azureSubscription: 'sub-workload-1'
resourceGroupName: '$(spokeResourceGroup0103)'
location: '$(spokeLocation0103)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(spokeVnetName0103) -remoteVnetName $(hubVNetName) -remoteVnetSubscriptionId "$(hubVnetSubId)" -remoteVnetResourceGroup $(hubResourceGroup)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Spoke VNet 0201 to Hub VNet'
inputs:
azureSubscription: 'sub-workload-2'
resourceGroupName: '$(spokeResourceGroup0201)'
location: '$(spokeLocation0201)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(spokeVnetName0201) -remoteVnetName $(hubVNetName) -remoteVnetSubscriptionId "$(hubVnetSubId)" -remoteVnetResourceGroup $(hubResourceGroup)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Spoke VNet 0202 to Hub VNet'
inputs:
azureSubscription: 'sub-workload-2'
resourceGroupName: '$(spokeResourceGroup0202)'
location: '$(spokeLocation0202)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(spokeVnetName0202) -remoteVnetName $(hubVNetName) -remoteVnetSubscriptionId "$(hubVnetSubId)" -remoteVnetResourceGroup $(hubResourceGroup)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Hub VNet to Spoke VNet 0101'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(hubVnetName) -remoteVnetName $(spokeVnetName0101) -remoteVnetSubscriptionId "$(spokeVnetSubId101)" -remoteVnetResourceGroup $(spokeResourceGroup0101)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Hub VNet to Spoke VNet 0102'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(hubVnetName) -remoteVnetName $(spokeVnetName0102) -remoteVnetSubscriptionId "$(spokeVnetSubId102)" -remoteVnetResourceGroup $(spokeResourceGroup0102)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Hub VNet to Spoke VNet 0103'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(hubVnetName) -remoteVnetName $(spokeVnetName0103) -remoteVnetSubscriptionId "$(spokeVnetSubId103)" -remoteVnetResourceGroup $(spokeResourceGroup0103)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Hub VNet to Spoke VNet 0201'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(hubVnetName) -remoteVnetName $(spokeVnetName0201) -remoteVnetSubscriptionId "$(spokeVnetSubId201)" -remoteVnetResourceGroup $(spokeResourceGroup0201)'
- task: AzureResourceGroupDeployment@2
displayName: 'Peer Hub VNet to Spoke VNet 0202'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/vNetPeering/vnet.peering.azuredeploy.json'
overrideParameters: '-localVnetName $(hubVnetName) -remoteVnetName $(spokeVnetName0202) -remoteVnetSubscriptionId "$(spokeVnetSubId202)" -remoteVnetResourceGroup $(spokeResourceGroup0202)'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Azure Private DNS Zone'
inputs:
azureSubscription: 'sub-mgmt'
resourceGroupName: '$(hubResourceGroup)'
location: '$(hubLocation)'
csmFile: '$(Agent.BuildDirectory)/drop/templates/private-dns-zone/private.dns.zone.azuredeploy.json'
overrideParameters: '-zoneName $(dnsZoneName) -LinkedVNetResourceIds ["$(hubVNetResourceId)", "$(spokeVNetResourceId101)", "$(spokeVNetResourceId102)", "$(spokeVNetResourceId103)", "$(spokeVNetResourceId201)", "$(spokeVNetResourceId202)"]'