Skip to content

Commit

Permalink
Merge pull request #46 from AlexanderSehr/users/alsehr/202412_smallFixes
Browse files Browse the repository at this point in the history
fix: Several improvements / fixes on the windows image-side of things
  • Loading branch information
AlexanderSehr authored Dec 29, 2024
2 parents ef2f8c3 + 78718e7 commit be43e75
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 269 deletions.
10 changes: 6 additions & 4 deletions .azuredevops/azureImageBuilder/.templates/pipeline.jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ parameters:
default:
- name: deploymentsToPerform
default:
- name: osType
default:
- name: waitForImageBuild
default:
- name: removeImageTemplateResources
Expand Down Expand Up @@ -63,7 +65,7 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ImageTemplate.ps1')
$functionInput = @{
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand All @@ -89,7 +91,7 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-DeploymentScript.ps1')
$functionInput = @{
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand All @@ -115,7 +117,7 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ResourcesInStagingRg.ps1')
$functionInput = @{
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand Down Expand Up @@ -186,7 +188,7 @@ jobs:
# INVOKE DEPLOYMENT #
# ----------------- #
$functionInput = @{
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
DeploymentMetadataLocation = '$(deploymentMetadataLocation)'
SubscriptionId = (Get-AzContext).Subscription.Id
RepoRoot = '$(System.DefaultWorkingDirectory)'
Expand Down
10 changes: 10 additions & 0 deletions .azuredevops/azureImageBuilder/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ parameters:
- Only base
- Only assets & image
- Only image
- name: osType
displayName: OS to create the image for
type: string
default: Linux
values:
- Linux
- Windows
- name: waitForImageBuild
displayName: Wait for image build
type: boolean
Expand All @@ -41,6 +48,7 @@ stages:
- template: .templates/pipeline.jobs.yml
parameters:
environment: 'sbx'
osType: '${{ lower(parameters.osType) }}'
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'
Expand All @@ -57,6 +65,7 @@ stages:
- template: .templates/pipeline.jobs.yml
parameters:
environment: 'dev'
osType: '${{ lower(parameters.osType) }}'
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'
Expand All @@ -74,6 +83,7 @@ stages:
- template: .templates/pipeline.jobs.yml
parameters:
environment: 'prd'
osType: '${{ lower(parameters.osType) }}'
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Currently the repository contains the following constructs:

| Construct | Description | Path |
| - | - | - |
| Azure Image Builder | This construct provides a packages solution to create custom images using the Azure Image Builder service with an Azure Compute Gallery, including guidelines to operate it. | [`constructs\azureImageBuilder`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/azureImageBuilder) |
| Managed DevOps Pool | This construct provides a packaged solution to deploy the infrastructure for self-hosted Managed DevOps Pools, including guidelines to maintain it. | [`constructs\managedDevOpsPool`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/managedDevOpsPool) |
| Azure Image Builder | This construct provides a packages solution to create custom images using the Azure Image Builder service with an Azure Compute Gallery, including guidelines to operate it. | [`constructs/azureImageBuilder`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/azureImageBuilder) |
| Managed DevOps Pool | This construct provides a packaged solution to deploy the infrastructure for self-hosted Managed DevOps Pools, including guidelines to maintain it. | [`constructs/managedDevOpsPool`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/managedDevOpsPool) |

For detailed information on the constructs and how to get started, please continue to the [Wiki](https://github.com/Azure/DevOps-Self-Hosted/wiki).

Expand Down
4 changes: 2 additions & 2 deletions constructs/azureImageBuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This construct consists of several components in different places. You can use the following table to make sure you are aware of all the ones you need:

- Construct Templates, Scripts & Deployment Files: Folder `constructs\azureImageBuilder`
- Azure DevOps Pipelines: Folder `.azuredevops\azureImageBuilder`
- Construct Templates, Scripts & Deployment Files: Folder `constructs/azureImageBuilder`
- Azure DevOps Pipelines: Folder `.azuredevops/azureImageBuilder`

For further information, please refer to the Wiki for information on how to apply the construct.
151 changes: 0 additions & 151 deletions constructs/azureImageBuilder/deploymentFiles/sbx.image.bicep

This file was deleted.

99 changes: 99 additions & 0 deletions constructs/azureImageBuilder/deploymentFiles/sbx.image.linux.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
targetScope = 'subscription'

//////////////////////////
// Input Parameters //
//////////////////////////
@description('Optional. A parameter to control which deployments should be executed')
@allowed([
'All'
'Only base'
'Only assets & image'
'Only image'
])
param deploymentsToPerform string = 'All'

@description('Optional. Specifies the location for resources.')
param resourceLocation string = 'NorthEurope'

@description('Optional. A parameter to control if the deployment should wait for the image build to complete.')
param waitForImageBuild bool = true

///////////////////////////////////////////////
// Multi-referenced deployment variables //
///////////////////////////////////////////////
var computeGalleryImageDefinitionName = 'sid-linux'
var assetsStorageAccountName = '<assetsStorageAccountName>'
var assetsStorageAccountContainerName = 'aibscripts'
var installPwshScriptName = 'Install-LinuxPowerShell.sh'
var initializeSoftwareScriptName = 'Initialize-LinuxSoftware.ps1'

/////////////////////////////
// Template deployment //
/////////////////////////////
module imageDeployment '../templates/image.deploy.bicep' = {
name: '${uniqueString(deployment().name, resourceLocation)}-image-sbx'
params: {
resourceLocation: resourceLocation
deploymentsToPerform: deploymentsToPerform
computeGalleryName: '<computeGalleryName>'
computeGalleryImageDefinitionName: computeGalleryImageDefinitionName
waitForImageBuild: waitForImageBuild
computeGalleryImageDefinitions: [
{
name: computeGalleryImageDefinitionName
osType: 'Linux'
identifier: {
publisher: 'devops'
offer: 'devops_linux'
sku: 'devops_linux_az'
}
osState: 'Generalized'
hyperVGeneration: 'V2'
}
]

assetsStorageAccountName: assetsStorageAccountName
assetsStorageAccountContainerName: assetsStorageAccountContainerName

storageAccountFilesToUpload: [
{
name: installPwshScriptName
value: loadTextContent('../scripts/uploads/linux/${installPwshScriptName}')
}
{
name: initializeSoftwareScriptName
value: loadTextContent('../scripts/uploads/linux/${initializeSoftwareScriptName}')
}
]
imageTemplateImageSource: {
type: 'PlatformImage'
publisher: 'canonical'
offer: '0001-com-ubuntu-server-jammy'
sku: '22_04-lts-gen2'
version: 'latest'
// Custom image example
// type: 'SharedImageVersion'
// imageVersionID: '${subscription().id}/resourceGroups/myRg/providers/Microsoft.Compute/galleries/<computeGalleryName>/images/${computeGalleryImageDefinitionName}/versions/0.24470.675'
}
imageTemplateCustomizationSteps: [
{
type: 'Shell'
name: 'PowerShell installation'
scriptUri: 'https://${assetsStorageAccountName}.blob.${az.environment().suffixes.storage}/${assetsStorageAccountContainerName}/${installPwshScriptName}'
}
{
type: 'File'
name: 'Download ${initializeSoftwareScriptName}'
sourceUri: 'https://${assetsStorageAccountName}.blob.${az.environment().suffixes.storage}/${assetsStorageAccountContainerName}/${initializeSoftwareScriptName}'
destination: initializeSoftwareScriptName
}
{
type: 'Shell'
name: 'Software installation'
inline: [
'pwsh \'${initializeSoftwareScriptName}\''
]
}
]
}
}
Loading

0 comments on commit be43e75

Please sign in to comment.