Skip to content

Commit

Permalink
Sq lserver2022 byoc (#133)
Browse files Browse the repository at this point in the history
* run packer fix on minimal-windows-server.json and remove disable_windows_background_services script

* Modify ParseImageFeaturesAndCustomScripts

* add Sql server 2022 option to image builder
  • Loading branch information
OwenMcDonnell authored Jun 6, 2023
1 parent 2a6d674 commit a0ec322
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 200 deletions.
19 changes: 18 additions & 1 deletion AppVeyorBYOC-Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function ValidateDependencies ($cloudType) {
}

function GetPackerPath ([switch]$prerelease) {
$packerVersion = if ($prerelease) {"1.4.5"} else {"1.4.3"}
$packerVersion = if ($prerelease) {"1.8.7"} else {"1.4.3"}
Write-host "`nChecking if Hashicorp Packer version $packerVersion is installed..." -ForegroundColor Cyan
if ((Get-Command packer -ErrorAction Ignore) -and (packer --version) -eq $packerVersion) {
Write-Host "Packer version $packerVersion found" -ForegroundColor DarkGray
Expand Down Expand Up @@ -319,12 +319,16 @@ function ParseImageFeaturesAndCustomScripts ($imageFeatures, $imageTemplate, $Im
$imageFeatures | % {
$scriptName1 = "install_$($_)_after_reboot.ps1"
$scriptName2 = "$($_)_after_reboot.ps1"
$scriptName3 = "install_$($_)_after_restart.ps1"
if (Test-Path "$PSScriptRoot/scripts/Windows/$scriptName1") {
$after_reboot_scripts += "{{ template_dir }}/scripts/Windows/$scriptName1"
}
elseif (Test-Path "$PSScriptRoot/scripts/Windows/$scriptName2") {
$after_reboot_scripts += "{{ template_dir }}/scripts/Windows/$scriptName2"
}
elseif (Test-Path "$PSScriptRoot/scripts/Windows/$scriptName3") {
$after_reboot_scripts += "{{ template_dir }}/scripts/Windows/$scriptName3"
}
}

$before_reboot = @{
Expand All @@ -350,6 +354,18 @@ function ParseImageFeaturesAndCustomScripts ($imageFeatures, $imageTemplate, $Im
}
$packer_file.provisioners +=$after_reboot
}

$disableWindowsFeatures = @{
'type' = 'powershell'
'scripts' = @("{{ template_dir }}/scripts/Windows/disable_windows_background_services.ps1")
'only' = @('hyperv-iso')
'elevated_user' = '{{user `install_user`}}'
'elevated_password' = '{{user `install_password`}}'
}

$packer_file.provisioners += $disableWindowsFeatures


}

if($ImageCustomScript) {
Expand Down Expand Up @@ -404,6 +420,7 @@ function ParseImageFeaturesAndCustomScripts ($imageFeatures, $imageTemplate, $Im
Copy-Item -Path "$PSScriptRoot\hyper-v" -Destination $(Split-Path $imageTemplateCustom -Parent) -recurse -Force
Copy-Item -Path "$PSScriptRoot\http" -Destination $(Split-Path $imageTemplateCustom -Parent) -recurse -Force
$packer_file | ConvertTo-Json -Depth 20 | Set-Content -Path $imageTemplateCustom

return $imageTemplateCustom
}

Expand Down
4 changes: 4 additions & 0 deletions byoc/image-builder-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
"id":"sql_server_2019",
"title":"SQL Server 2019 Developer Edition"
},
{
"id":"sql_server_2022",
"title":"SQL Server 2022 Developer Edition"
},
{
"id":"nodejs_latest",
"title":"Node.js"
Expand Down
Loading

0 comments on commit a0ec322

Please sign in to comment.