-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5bc3527
Showing
197 changed files
with
14,051 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
.azuredevops/azureDevOpsScaleSet/.templates/pipeline.scaleset.jobs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
parameters: | ||
- name: environment | ||
default: | ||
- name: deploymentsToPerform | ||
default: | ||
- name: serviceConnection | ||
default: | ||
- name: waitForscalesetBuild | ||
default: | ||
|
||
jobs: | ||
- deployment: deploy_job | ||
displayName: Deploy Resources | ||
environment: ${{ parameters.environment }} | ||
timeoutInMinutes: 120 | ||
pool: | ||
vmImage: '$(vmImage_${{ parameters.environment }})' | ||
name: '$(poolName_${{ parameters.environment }})' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: self | ||
# [Deployment] task(s) | ||
#--------------------- | ||
- task: AzurePowerShell@4 | ||
displayName: 'Deploy [scaleset.deploy.bicep] via service connection [$(serviceConnection_${{ parameters.environment }})]' | ||
name: deploy_task | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'New-ModuleDeployment.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Test-TemplateWithParameterFile.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Set-CustomParameter') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Select-Image.ps1') | ||
# Check the provide image | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.scaleset.parameters.json' | ||
$parameterFileContent = ConvertFrom-Json (Get-Content $parameterFilePath -Raw) -AsHashTable | ||
if($imageVersionReference = Select-Image -imageReference $parameterFileContent.parameters.vmssParam.value.imageReference -Verbose) { | ||
$customValueMap += @{ | ||
path = 'vmssParam.value.imageReference.id' | ||
value = $imageVersionReference | ||
} | ||
} | ||
# Overwrite parameter file if necessary | ||
if($customValueMap.Count -gt 0) { | ||
$overwriteInputObject = @{ | ||
parameterFilePath = $parameterFilePath | ||
valueMap = $customValueMap | ||
} | ||
Set-CustomParameter @overwriteInputObject | ||
} | ||
# ----------------- # | ||
# INVOKE DEPLOYMENT # | ||
# ----------------- # | ||
$functionInput = @{ | ||
templateFilePath = Join-Path '$(templatesPath)' 'scaleset.deploy.bicep' | ||
parameterFilePath = $parameterFilePath | ||
location = '$(location)' | ||
subscriptionId = (Get-AzContext).Subscription.Id | ||
} | ||
# Inject control parmaeters from pipeline | ||
$functionInput['additionalParameters'] = @{ | ||
deploymentsToPerform = '${{ parameters.deploymentsToPerform }}' | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
# Validate deployment | ||
Test-TemplateWithParameterFile @functionInput | ||
# Invoke deployment | ||
New-ModuleDeployment @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: 'ScaleSet Deployment' | ||
|
||
parameters: | ||
- name: startEnvironment | ||
displayName: Environment to start from | ||
type: string | ||
default: sbx | ||
values: | ||
- sbx | ||
- dev | ||
- prd | ||
- name: deploymentsToPerform | ||
displayName: Scope of deployment | ||
type: string | ||
default: Only Scale Set | ||
values: | ||
- All | ||
- Only Scale Set | ||
variables: | ||
- template: variables.yml | ||
|
||
trigger: none | ||
|
||
stages: | ||
- stage: SBX_Deployments | ||
displayName: Deploy to SBX | ||
condition: and(succeeded(), eq('${{ parameters.startEnvironment }}', 'sbx')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'sbx' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
|
||
- stage: DEV_Deployments | ||
displayName: Deploy to DEV | ||
condition: and(succeeded(), in('${{ parameters.startEnvironment }}', 'sbx', 'dev')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'dev' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
|
||
- stage: PRD_Deployments | ||
displayName: Deploy to PRD | ||
condition: and(succeeded(),in('${{ parameters.startEnvironment }}', 'sbx', 'dev', 'prd')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'prd' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
####################################################################### | ||
## NOTE ## | ||
## ------------------------------------------------------------------## | ||
## - These variables are used to configure the pipeline and provide ## | ||
## variables to pipeline scripts ## | ||
## - Parameters used for resource deployments are located in the ## | ||
## parameter files in the '.\Parameters' folder ## | ||
####################################################################### | ||
|
||
variables: | ||
############# | ||
## GENERAL ## | ||
############# | ||
#region shared | ||
vmImage_sbx: 'ubuntu-latest' # Use this for microsoft-hosted agents | ||
vmImage_dev: 'ubuntu-latest' # Use this for microsoft-hosted agents | ||
vmImage_prd: 'ubuntu-latest' # Use this for microsoft-hosted agents | ||
|
||
poolName_sbx: '' # Use this for self-hosted agents | ||
poolName_dev: '' # Use this for self-hosted agents | ||
poolName_prd: '' # Use this for self-hosted agents | ||
|
||
serviceConnection_sbx: 'CARML-CSU-Tenant-Connection' | ||
serviceConnection_dev: 'CARML-CSU-Tenant-Connection' | ||
serviceConnection_prd: 'CARML-CSU-Tenant-Connection' | ||
#endregion | ||
|
||
#region specific | ||
templatesPath: 'constructs/azureDevOpsScaleSet/templates' | ||
parametersPath: 'constructs/azureDevOpsScaleSet/parameters' | ||
orchestrationFunctionsPath: 'constructs/azureDevOpsScaleSet/scripts' | ||
sharedOrchestrationFunctionsPath: 'sharedScripts' | ||
location: westeurope | ||
#endregion |
216 changes: 216 additions & 0 deletions
216
.azuredevops/azureImageBuilder/.templates/pipeline.image.jobs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
parameters: | ||
- name: environment | ||
default: | ||
- name: deploymentsToPerform | ||
default: | ||
- name: waitForImageBuild | ||
default: | ||
- name: removeImageTemplateResources | ||
default: true | ||
|
||
jobs: | ||
- deployment: cleanup_job | ||
displayName: Remove previous Image Template resources | ||
environment: ${{ parameters.environment }} | ||
timeoutInMinutes: 120 | ||
condition: | | ||
and( | ||
succeeded(), | ||
eq('${{ parameters.removeImageTemplateResources }}', 'true') | ||
) | ||
pool: | ||
vmImage: '$(vmImage_${{ parameters.environment }})' | ||
name: '$(poolName_${{ parameters.environment }})' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: self | ||
- task: AzurePowerShell@4 | ||
displayName: 'Remove previous image template resources' | ||
name: Remove_ImageTemplates_Task | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
Write-Verbose "Load function" -Verbose | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ImageTemplate.ps1') | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.parameters.json' | ||
$parameters = (ConvertFrom-Json (Get-Content -Path $parameterFilePath -Raw)).parameters | ||
$functionInput = @{ | ||
resourcegroupName = $parameters.rgParam.value.name | ||
imageTemplateName = $parameters.itParam.value.name | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
Remove-ImageTemplate @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
- deployment: deploy_job | ||
displayName: Deploy Resources | ||
environment: ${{ parameters.environment }} | ||
condition: in('${{ parameters.deploymentsToPerform }}', 'All', 'Only infrastructure', 'Only storage & image', 'Only image', '') | ||
timeoutInMinutes: 120 | ||
pool: | ||
vmImage: '$(vmImage_${{ parameters.environment }})' | ||
name: '$(poolName_${{ parameters.environment }})' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: self | ||
- task: AzurePowerShell@4 | ||
displayName: 'Deploy [imageInfra.deploy.bicep] via service connection [$(serviceConnection_${{ parameters.environment }})]' | ||
condition: | | ||
and( | ||
succeeded(), | ||
in('${{ parameters.deploymentsToPerform }}', 'All', 'Only infrastructure', 'Only storage & image') | ||
) | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'New-ModuleDeployment.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Test-TemplateWithParameterFile') | ||
# ----------------- # | ||
# INVOKE DEPLOYMENT # | ||
# ----------------- # | ||
$functionInput = @{ | ||
templateFilePath = Join-Path '$(templatesPath)' 'imageInfra.deploy.bicep' | ||
parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageInfra.parameters.json' | ||
location = '$(location)' | ||
subscriptionId = (Get-AzContext).Subscription.Id | ||
} | ||
# Inject control parmaeters from pipeline | ||
$functionInput['additionalParameters'] = @{ | ||
deploymentsToPerform = '${{ parameters.deploymentsToPerform }}' | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
# Validate deployment | ||
Test-TemplateWithParameterFile @functionInput | ||
# Invoke deployment | ||
New-ModuleDeployment @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
|
||
- task: AzurePowerShell@4 | ||
displayName: "Trigger Storage Account post-deployment" | ||
condition: | | ||
and( | ||
succeeded(), | ||
in('${{ parameters.deploymentsToPerform }}', 'All', 'Only infrastructure', 'Only storage & image') | ||
) | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
Write-Verbose "Load function" -Verbose | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'storage' 'Invoke-StorageAccountPostDeployment.ps1') | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageInfra.parameters.json' | ||
$parameters = (ConvertFrom-Json (Get-Content -Path $parameterFilePath -Raw)).parameters | ||
$functionInput = @{ | ||
storageAccountName = $parameters.saParam.value.name | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
Invoke-StorageAccountPostDeployment @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
|
||
- task: AzurePowerShell@4 | ||
displayName: 'Deploy [imageTemplate.deploy.bicep] via service connection [$(serviceConnection_${{ parameters.environment }})]' | ||
condition: | | ||
and( | ||
succeeded(), | ||
in('${{ parameters.deploymentsToPerform }}', 'All', 'Only storage & image', 'Only image') | ||
) | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'New-ModuleDeployment.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Test-TemplateWithParameterFile') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'storage' 'Set-SasKeysInFile.ps1') | ||
# ----------------- # | ||
# INVOKE DEPLOYMENT # | ||
# ----------------- # | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.parameters.json' | ||
$functionInput = @{ | ||
templateFilePath = Join-Path '$(templatesPath)' 'imageTemplate.deploy.bicep' | ||
parameterFilePath = $parameterFilePath | ||
location = '$(location)' | ||
subscriptionId = (Get-AzContext).Subscription.Id | ||
} | ||
# Inject control parmaeters from pipeline | ||
$functionInput['additionalParameters'] = @{ | ||
deploymentsToPerform = '${{ parameters.deploymentsToPerform }}' | ||
} | ||
# Set SAS keys for storage references | ||
Set-SasKeysInFile -filePath $parameterFilePath -Verbose | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
# Validate deployment | ||
Test-TemplateWithParameterFile @functionInput | ||
# Invoke deployment | ||
$res = New-ModuleDeployment @functionInput -Verbose | ||
Write-Verbose ($res | ConvertTo-Json | Out-String) -Verbose | ||
foreach ($outputKey in $res.deploymentOutput.Keys) { | ||
Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) | ||
} | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
|
||
- task: AzurePowerShell@4 | ||
displayName: "Wait for image build" | ||
condition: | | ||
and( | ||
succeeded(), | ||
eq('${{ parameters.waitForImageBuild }}', 'true'), | ||
in('${{ parameters.deploymentsToPerform }}', 'All', 'Only infrastructure', 'Only storage & image', 'Only image') | ||
) | ||
name: PostDeploy_ImageTemplates_Task | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
Write-Verbose "Load function" -Verbose | ||
. '$(Build.Repository.LocalPath)/$(orchestrationFunctionsPath)/image/Wait-ForImageBuild.ps1' | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.parameters.json' | ||
$parameters = (ConvertFrom-Json (Get-Content -Path $parameterFilePath -Raw)).parameters | ||
$functionInput = @{ | ||
ResourceGroupName = $parameters.rgParam.value.name | ||
ImageTemplateName = $env:IMAGETEMPATENAME # template deployment output | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
Wait-ForImageBuild @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion |
Oops, something went wrong.