21 Commits

Author SHA1 Message Date
98a6e636fb Revert package manager (not compatible with winRM!!!)
All checks were successful
continuous-integration/drone/push Build is passing
2021-07-05 17:07:04 +02:00
a3e4fb98eb Attempt package manager installation with provided license
All checks were successful
continuous-integration/drone/push Build is passing
2021-07-05 15:52:43 +02:00
b041658fbf Testing wrt VMware Tools auto-start
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-29 13:12:10 +02:00
6a18b5bf22 Adjust package manager install to new release format
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-25 15:08:03 +02:00
de5546f776 Try once more to switch package manager
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-25 12:39:39 +02:00
c262c55e06 Fix paths (forgot to stage the changes in previous commit :P)
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-24 13:25:30 +02:00
567e7e64f9 Housekeeping;Add prereq module installation
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-24 10:14:22 +02:00
16575d1db4 Disable baremetal for now;Add to package manager install logic
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-24 09:26:21 +02:00
0c19c023de Fix pvscsi dedicated xml reference
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-06-24 09:03:06 +02:00
0958d6a352 Retry winget package manager
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-23 21:55:07 +02:00
8f1dd67224 Reorder autounattend.xml #2
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-06-23 13:01:23 +02:00
67d70f58f8 Try more elaborate autounattend configuration
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-06-23 12:53:34 +02:00
9868c43b14 Change autounattend XML order
Some checks are pending
continuous-integration/drone/push Build is running
2021-06-23 09:44:11 +02:00
11ea6f68ee Specify pvscsi drivers
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-06-23 09:30:15 +02:00
e5487a22f3 Try pvscsi controller without extra drivers
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-06-23 09:05:17 +02:00
2487003d08 Change controller for baremetal
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-22 19:40:08 +02:00
5597046178 Revert package manager to chocolatey 2021-06-22 16:41:19 +02:00
6228c8db35 Decrease packer VM RAM
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-22 15:47:47 +02:00
84d449dadb Fix dependencies for package manager
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-22 13:44:06 +02:00
51f6a7c7bd Force pull container image
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-22 11:23:43 +02:00
248ac46d5f Fix typo 2021-06-22 10:36:21 +02:00
7 changed files with 315 additions and 42 deletions

View File

@@ -13,13 +13,16 @@ volumes:
steps: steps:
- name: Debugging information - name: Debugging information
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands: commands:
- yamllint --version - yamllint --version
- packer --version - packer --version
- pwsh --version - qemu-img --version
- ovftool --version - ovftool --version
- pwsh --version
- name: Windows Server 2019 - name: Windows Server 2019
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands: commands:
- sed -i -e "s/<<img-productkey>>/$${PRODUCTKEY}/" packer/preseed/Server2019/Autounattend.xml - sed -i -e "s/<<img-productkey>>/$${PRODUCTKEY}/" packer/preseed/Server2019/Autounattend.xml
- | - |
@@ -69,6 +72,7 @@ steps:
path: /scratch path: /scratch
- name: Remove temporary resources - name: Remove temporary resources
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands: commands:
- | - |
pwsh -file scripts/Remove-Resources.ps1 \ pwsh -file scripts/Remove-Resources.ps1 \

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing/>
<settings pass="auditSystem">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DriverPaths>
<PathAndCredentials wcm:action="add" wcm:keyValue="1">
<Path>E:\Program Files\VMware\VMware Tools\Drivers\pvscsi\Win8\amd64</Path>
</PathAndCredentials>
</DriverPaths>
</component>
</settings>
<settings pass="windowsPE">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Extend>false</Extend>
<Format>NTFS</Format>
<Letter>C</Letter>
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>Windows Server 2019</Label>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
<WillShowUI>OnError</WillShowUI>
</DiskConfiguration>
<UserData>
<AcceptEula>true</AcceptEula>
<!-- <FullName>Spamasaurus Rex</FullName>
<Organization>Spamasaurus Rex</Organization> -->
<ProductKey>
<Key><<img-productkey>></Key>
<WillShowUI>Never</WillShowUI>
</ProductKey>
</UserData>
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>1</PartitionID>
</InstallTo>
<WillShowUI>OnError</WillShowUI>
<InstallToAvailablePartition>false</InstallToAvailablePartition>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key>
<Value>4</Value>
</MetaData>
</InstallFrom>
</OSImage>
</ImageInstall>
</component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="offlineServicing">
<component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<EnableLUA>false</EnableLUA>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<UserAccounts>
<AdministratorPassword>
<Value><<img-password>></Value>
<PlainText>true</PlainText>
</AdministratorPassword>
</UserAccounts>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Home</NetworkLocation>
<ProtectYourPC>1</ProtectYourPC>
</OOBE>
<AutoLogon>
<Password>
<Value><<img-password>></Value>
<PlainText>true</PlainText>
</Password>
<Username>administrator</Username>
<Enabled>true</Enabled>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
<Description>Set execution policy 64bit</Description>
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
<Description>Set execution policy 32bit</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c reg add "HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff"</CommandLine>
<Description>Disable new network prompt</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\Set-NetworkProfile.ps1</CommandLine>
<Description>Set network profile to private</Description>
<Order>4</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\Disable-WinRM.ps1</CommandLine>
<Description>Disable WinRM</Description>
<Order>5</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c a:\Install-VMwareTools.cmd</CommandLine>
<Order>13</Order>
<Description>Install VMware Tools</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\Enable-WinRM.ps1</CommandLine>
<Description>Enable WinRM</Description>
<Order>99</Order>
</SynchronousCommand>
</FirstLogonCommands>
<ShowWindowsLive>false</ShowWindowsLive>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<OEMInformation>
<HelpCustomized>false</HelpCustomized>
</OEMInformation>
<!-- Rename computer here. -->
<ComputerName>packer-template</ComputerName>
<TimeZone>W. Europe Standard Time</TimeZone>
<RegisteredOwner/>
</component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
</settings>
</unattend>

View File

@@ -30,7 +30,7 @@ source "vsphere-iso" "srv2019-template" {
winrm_password = var.winrm_password winrm_password = var.winrm_password
winrm_timeout = "10m" winrm_timeout = "10m"
RAM = 8192 RAM = 4096
CPUs = 2 CPUs = 2
network_adapters { network_adapters {
@@ -89,7 +89,7 @@ source "vsphere-iso" "srv2019-virtual" {
winrm_timeout = "10m" winrm_timeout = "10m"
winrm_username = "administrator" winrm_username = "administrator"
RAM = 8192 RAM = 4096
CPUs = 2 CPUs = 2
network_adapters { network_adapters {
@@ -148,7 +148,7 @@ source "vsphere-iso" "srv2019-baremetal" {
winrm_password = var.winrm_password winrm_password = var.winrm_password
winrm_timeout = "10m" winrm_timeout = "10m"
RAM = 8192 RAM = 4096
CPUs = 2 CPUs = 2
network_adapters { network_adapters {
@@ -159,11 +159,11 @@ source "vsphere-iso" "srv2019-baremetal" {
disk_size = 20480 disk_size = 20480
disk_thin_provisioned = true disk_thin_provisioned = true
} }
disk_controller_type = ["lsilogic-sas"] disk_controller_type = ["pvscsi"]
usb_controller = ["xhci"] usb_controller = ["xhci"]
floppy_files = [ floppy_files = [
"packer/preseed/Server2019/Autounattend.xml", "packer/preseed/Server2019/pvscsi/Autounattend.xml",
"packer/preseed/Server2019/Sysprep_Unattend.xml", "packer/preseed/Server2019/Sysprep_Unattend.xml",
"scripts/Set-NetworkProfile.ps1", "scripts/Set-NetworkProfile.ps1",
"scripts/Disable-WinRM.ps1", "scripts/Disable-WinRM.ps1",
@@ -185,44 +185,49 @@ source "vsphere-iso" "srv2019-baremetal" {
} }
build { build {
// sources = [
// "source.vsphere-iso.srv2019-template",
// "source.vsphere-iso.srv2019-virtual",
// "source.vsphere-iso.srv2019-baremetal"
// ]
sources = [ sources = [
"source.vsphere-iso.srv2019-template", "source.vsphere-iso.srv2019-template",
"source.vsphere-iso.srv2019-virtual", "source.vsphere-iso.srv2019-virtual"
"source.vsphere-iso.srv2019-baremetal"
] ]
provisioner "windows-update" { provisioner "windows-update" {
} }
// provisioner "powershell" {
// scripts = [
// "scripts/Install-Prerequisites.ps1",
// "scripts/Install-WinGet.ps1"
// ]
// }
// provisioner "powershell" {
// inline = [
// "winget install mozilla.firefox",
// "winget install 7zip.7zip",
// "winget install microsoft.dotnetframework"
// ]
// // valid_exit_codes = [0, 3010]
// }
provisioner "powershell" { provisioner "powershell" {
scripts = [ inline = [
"scripts/Install-WinGet.ps1" "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
"Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
] ]
} }
provisioner "powershell" { provisioner "powershell" {
inline = [ inline = [
"winget install mozilla.firefox", "choco config set --name=limit-output --value=LimitOutput",
"winget install 7zip.7zip", "choco install -y dotnetfx",
"winget install microsoft.dotnetframework" "choco install -y 7zip.install",
"choco install -y sysinternals",
"choco install -y firefox"
] ]
// valid_exit_codes = [0, 3010] valid_exit_codes = [0, 3010]
} }
// provisioner "powershell" {
// inline = [
// "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
// "Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
// ]
// }
// provisioner "powershell" {
// inline = [
// "choco config set --name=limit-output --value=LimitOutput",
// "choco install -y dotnetfx",
// "choco install -y 7zip.install",
// "choco install -y sysinternals",
// "choco install -y firefox"
// ]
// valid_exit_codes = [0, 3010]
// }
provisioner "windows-update" { provisioner "windows-update" {
} }
@@ -237,13 +242,13 @@ build {
provisioner "file" { provisioner "file" {
only = ["vsphere-iso.srv2019-virtual"] only = ["vsphere-iso.srv2019-virtual"]
destination = "C:\\Payload\\" destination = "C:\\Payload\\"
source = "scripts/Server2019/payload/" source = "scripts/payload/"
} }
provisioner "powershell" { provisioner "powershell" {
only = ["vsphere-iso.srv2019-virtual"] only = ["vsphere-iso.srv2019-virtual"]
scripts = [ scripts = [
"scripts/Server2019/Register-ScheduledTask.ps1" "scripts/Register-ScheduledTask.ps1"
] ]
} }

View File

@@ -0,0 +1,40 @@
[CmdletBinding()]
Param(
# No parameters
)
$RequiredPSModules = @(
'ntobjectmanager' # Provides cmdlet 'Set-ExecutionAlias'
)
$InstallPackageProviderSplat = @{
Name = 'NuGet'
MinimumVersion = '2.8.5.201'
Force = $True
Confirm = $False
}
Install-PackageProvider @InstallPackageProviderSplat
$SetPSRepositorySplat = @{
Name = 'PSGallery'
InstallationPolicy = 'Trusted'
}
Set-PSRepository @SetPSRepositorySplat
$InstallModuleSplat = @{
Name = $RequiredPSModules
Force = $True
Confirm = $False
}
Install-Module @InstallModuleSplat
$SetPSRepositorySplat = @{
Name = 'PSGallery'
InstallationPolicy = 'Untrusted'
}
Set-PSRepository @SetPSRepositorySplat
# Double check whether the required PowerShell modules are available
ForEach ($Module in $RequiredPSModules) {
If ([boolean](Get-Module -Name $Module -ListAvailable) -ne $True) {
Write-Error -Message "Missing PowerShell module '$($Module)'"
Exit 1
}
}

View File

@@ -1,18 +1,74 @@
#Requires -Modules 'NtObjectManager'
[CmdletBinding()] [CmdletBinding()]
Param( Param(
# None # None
) )
# Download dependencies
$AppxDependencies = @(
@{
ShortName = 'vclibs'
QualifiedName = 'Microsoft.VCLibs.140.00_8wekyb3d8bbwe'
},
@{
ShortName = 'vclibsuwp'
QualifiedName = 'Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe'
}
)
ForEach ($Dependency in $AppxDependencies) {
$InvokeWebRequestSplat = @{
Uri = 'https://store.rg-adguard.net/api/GetFiles'
Method = 'POST'
ContentType = 'application/x-www-form-urlencoded'
Body = "type=PackageFamilyName&url=$($Dependency.QualifiedName)&ring=RP&lang=en-US"
UseBasicParsing = $True
}
$InvokeWebRequestSplat = @{
Uri = ((Invoke-WebRequest @InvokeWebRequestSplat).Links | Where-Object {$_.OuterHTML -match '.appx' -and $_.outerHTML -match 'x64'}).href
OutFile = "$env:temp/$($Dependency.ShortName).appx"
}
Invoke-WebRequest @InvokeWebRequestSplat
}
# Download latest release (along with license) from github
$InvokeRestMethodSplat = @{ $InvokeRestMethodSplat = @{
Uri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" Uri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
Method = 'GET' Method = 'GET'
} }
$LatestRelease = Invoke-RestMethod @InvokeRestMethodSplat
$InvokeWebRequestSplat = @{ $InvokeWebRequestSplat = @{
Uri = ((Invoke-RestMethod @InvokeRestMethodSplat).assets | Where-Object ${_.name -like '*.appxbundle'}).browser_download_url Uri = ($LatestRelease.assets | Where-Object {$_.name -like '*.msixbundle'}).browser_download_url
Out = "$env:temp\winget.appxbundle" OutFile = "$env:temp\winget.msixbundle"
}
Invoke-WebRequest @InvokeWebRequestSplat
$InvokeWebRequestSplat = @{
Uri = ($LatestRelease.assets | Where-Object {$_.name -like '*license*.xml'}).browser_download_url
OutFile = "$env:temp\wingetlicense.xml"
} }
Invoke-WebRequest @InvokeWebRequestSplat Invoke-WebRequest @InvokeWebRequestSplat
If (Test-Path -Path "$env:temp\winget.appxbundle") { # Install dependencies
& dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"$env:temp\winget.appxbundle" /SkipLicense $AppxDependencies.ShortName | ForEach-Object {
$AddAppxPackageSplat = @{
Path = "$env:temp/$($_).appx"
}
Add-AppxPackage @AddAppxPackageSplat
} }
# Install winget
$AddAppxProvisionedPackageSplat = @{
Online = $True
PackagePath = "$env:temp\winget.msixbundle"
LicensePath = "$env:temp\wingetlicense.xml"
}
Add-AppxProvisionedPackage @AddAppxProvisionedPackageSplat
# Create reparse point
$SetExecutionAliasSplat = @{
Path = "$([System.Environment]::SystemDirectory)\winget.exe"
PackageName = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"
EntryPoint = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!winget"
Target = "$((Get-AppxPackage Microsoft.DesktopAppInstaller).InstallLocation)\AppInstallerCLI.exe"
AppType = 'Desktop'
Version = 3
}
Set-ExecutionAlias @SetExecutionAliasSplat
& explorer.exe "shell:appsFolder\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!winget"