Compare commits
29 Commits
3334ec7117
...
Server2019
Author | SHA1 | Date | |
---|---|---|---|
98a6e636fb | |||
a3e4fb98eb | |||
b041658fbf | |||
6a18b5bf22 | |||
de5546f776 | |||
c262c55e06 | |||
567e7e64f9 | |||
16575d1db4 | |||
0c19c023de | |||
0958d6a352 | |||
8f1dd67224 | |||
67d70f58f8 | |||
9868c43b14 | |||
11ea6f68ee | |||
e5487a22f3 | |||
2487003d08 | |||
5597046178 | |||
6228c8db35 | |||
84d449dadb | |||
51f6a7c7bd | |||
248ac46d5f | |||
5b0a8fc7df | |||
83baeefea0 | |||
1459e6dead | |||
1e699d62a2 | |||
1e885beb45 | |||
01e2fff44f | |||
fa6f029812 | |||
ca2d75d18b |
15
.drone.yml
15
.drone.yml
@@ -11,8 +11,18 @@ volumes:
|
||||
name: flexvolsmb-drone-scratch
|
||||
|
||||
steps:
|
||||
- name: Debugging information
|
||||
image: bv11-cr01.bessems.eu/library/packer-extended
|
||||
pull: always
|
||||
commands:
|
||||
- yamllint --version
|
||||
- packer --version
|
||||
- qemu-img --version
|
||||
- ovftool --version
|
||||
- pwsh --version
|
||||
- name: Windows Server 2019
|
||||
image: bv11-cr01.bessems.eu/library/packer-extended
|
||||
pull: always
|
||||
commands:
|
||||
- sed -i -e "s/<<img-productkey>>/$${PRODUCTKEY}/" packer/preseed/Server2019/Autounattend.xml
|
||||
- |
|
||||
@@ -62,6 +72,7 @@ steps:
|
||||
path: /scratch
|
||||
- name: Remove temporary resources
|
||||
image: bv11-cr01.bessems.eu/library/packer-extended
|
||||
pull: always
|
||||
commands:
|
||||
- |
|
||||
pwsh -file scripts/Remove-Resources.ps1 \
|
||||
@@ -79,12 +90,12 @@ steps:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
- name: Trigger downstream builds
|
||||
- name: Trigger downstream builds
|
||||
image: plugins/downstream
|
||||
settings:
|
||||
server: https://ci.spamasaurus.com
|
||||
token:
|
||||
from_secret: drone_token
|
||||
from_secret: drone_token
|
||||
fork: true
|
||||
repositories:
|
||||
- djpbessems/Packer.Images@ADCS
|
||||
|
5
packer/iso.auto.pkrvars.hcl
Normal file
5
packer/iso.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
iso_url = "sn.itch.fyi/Repository/iso/Microsoft/Windows%20Server%202019/LTSC/en_windows_server_2019_x64_dvd_4cb967d8.iso"
|
||||
iso_checksum = "sha256:4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d"
|
||||
iso_paths = [
|
||||
"ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
|
||||
]
|
168
packer/preseed/Server2019/pvscsi/Autounattend.xml
Normal file
168
packer/preseed/Server2019/pvscsi/Autounattend.xml
Normal 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>
|
@@ -15,5 +15,13 @@ variable "vm_name" {}
|
||||
variable "vm_guestos" {}
|
||||
variable "winrm_password" {}
|
||||
|
||||
variable "iso_url" {}
|
||||
variable "iso_checksum" {}
|
||||
variable "iso_paths" {}
|
||||
variable "repo_username" {}
|
||||
variable "repo_password" {}
|
||||
|
||||
local "iso_authenticatedurl" {
|
||||
expression = "https://${var.repo_username}:${var.repo_password}@${var.iso_url}"
|
||||
sensitive = true
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"vcenter_server": "bv11-vc.bessems.lan",
|
||||
"vsphere_username": "administrator@vsphere.local",
|
||||
"vsphere_datacenter": "DeSchakel",
|
||||
"vsphere_host": "bv11-esx.bessems.lan",
|
||||
"vsphere_hostip": "192.168.11.200",
|
||||
"vsphere_datastore": "Datastore01.SSD",
|
||||
"vsphere_folder": "/Packer",
|
||||
"vsphere_templatefolder": "/Templates",
|
||||
"vsphere_network": "LAN"
|
||||
}
|
@@ -1,234 +0,0 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "vsphere-iso",
|
||||
"name": "srv2019-t",
|
||||
|
||||
"vcenter_server": "{{user `vcenter_server`}}",
|
||||
"username": "{{user `vsphere_username`}}",
|
||||
"password": "{{user `vsphere_password`}}",
|
||||
"insecure_connection": "true",
|
||||
|
||||
"vm_name": "{{user `vm_guestos`}}-{{user `vm_name`}}-t",
|
||||
"datastore": "{{user `vsphere_datastore`}}",
|
||||
"folder": "{{user `vsphere_folder`}}",
|
||||
"datacenter": "{{user `vsphere_datacenter`}}",
|
||||
"host": "{{user `vsphere_host`}}",
|
||||
"boot_order": "disk,cdrom",
|
||||
|
||||
"guest_os_type": "windows9Server64Guest",
|
||||
|
||||
"communicator": "winrm",
|
||||
"winrm_username": "administrator",
|
||||
"winrm_password": "{{user `winrm_password`}}",
|
||||
"winrm_timeout": "10m",
|
||||
|
||||
"cpus": 2,
|
||||
"RAM": 8192,
|
||||
|
||||
"network_adapters": [
|
||||
{
|
||||
"network": "{{user `vsphere_network`}}",
|
||||
"network_card": "vmxnet3"
|
||||
}
|
||||
],
|
||||
"storage": [
|
||||
{
|
||||
"disk_size": 20480,
|
||||
"disk_thin_provisioned": true
|
||||
}
|
||||
],
|
||||
"disk_controller_type": "lsilogic-sas",
|
||||
"usb_controller": "xhci",
|
||||
|
||||
"iso_url": "https://{{user `repo_username`}}:{{user `repo_password`}}@sn.itch.fyi/Repository/iso/Microsoft/Windows%20Server%202019/LTSC/en_windows_server_2019_x64_dvd_4cb967d8.iso",
|
||||
"iso_checksum": "sha256:4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d",
|
||||
"iso_paths": [
|
||||
"ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
|
||||
],
|
||||
"remove_cdrom": true,
|
||||
|
||||
"floppy_files": [
|
||||
"packer/preseed/Server2019/Autounattend.xml",
|
||||
"packer/preseed/Server2019/Sysprep_Unattend.xml",
|
||||
"scripts/Set-NetworkProfile.ps1",
|
||||
"scripts/Disable-WinRM.ps1",
|
||||
"scripts/Enable-WinRM.ps1",
|
||||
"scripts/Install-VMwareTools.cmd"
|
||||
],
|
||||
|
||||
"boot_command": "",
|
||||
"boot_wait": "5m",
|
||||
|
||||
"shutdown_command": "C:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /unattend:A:\\Sysprep_Unattend.xml",
|
||||
"shutdown_timeout": "1h",
|
||||
|
||||
"export": {
|
||||
"images": false,
|
||||
"output_directory": "/scratch/srv2019-t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "vsphere-iso",
|
||||
"name": "srv2019-v",
|
||||
|
||||
"vcenter_server": "{{user `vcenter_server`}}",
|
||||
"username": "{{user `vsphere_username`}}",
|
||||
"password": "{{user `vsphere_password`}}",
|
||||
"insecure_connection": "true",
|
||||
|
||||
"vm_name": "{{user `vm_guestos`}}-{{user `vm_name`}}-v",
|
||||
"datastore": "{{user `vsphere_datastore`}}",
|
||||
"folder": "{{user `vsphere_folder`}}",
|
||||
"datacenter": "{{user `vsphere_datacenter`}}",
|
||||
"host": "{{user `vsphere_host`}}",
|
||||
"boot_order": "disk,cdrom",
|
||||
|
||||
"guest_os_type": "windows9Server64Guest",
|
||||
|
||||
"communicator": "winrm",
|
||||
"winrm_username": "administrator",
|
||||
"winrm_password": "{{user `winrm_password`}}",
|
||||
"winrm_timeout": "10m",
|
||||
|
||||
"cpus": 2,
|
||||
"RAM": 8192,
|
||||
|
||||
"network_adapters": [
|
||||
{
|
||||
"network": "{{user `vsphere_network`}}",
|
||||
"network_card": "vmxnet3"
|
||||
}
|
||||
],
|
||||
"storage": [
|
||||
{
|
||||
"disk_size": 20480,
|
||||
"disk_thin_provisioned": true
|
||||
}
|
||||
],
|
||||
"disk_controller_type": "lsilogic-sas",
|
||||
"usb_controller": "xhci",
|
||||
|
||||
"iso_url": "https://{{user `repo_username`}}:{{user `repo_password`}}@sn.itch.fyi/Repository/iso/Microsoft/Windows%20Server%202019/LTSC/en_windows_server_2019_x64_dvd_4cb967d8.iso",
|
||||
"iso_checksum": "sha256:4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d",
|
||||
"iso_paths": [
|
||||
"ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
|
||||
],
|
||||
"remove_cdrom": true,
|
||||
|
||||
"floppy_files": [
|
||||
"packer/preseed/Server2019/Autounattend.xml",
|
||||
"packer/preseed/Server2019/Sysprep_Unattend.xml",
|
||||
"scripts/Set-NetworkProfile.ps1",
|
||||
"scripts/Disable-WinRM.ps1",
|
||||
"scripts/Enable-WinRM.ps1",
|
||||
"scripts/Install-VMwareTools.cmd"
|
||||
],
|
||||
|
||||
"boot_command": "",
|
||||
"boot_wait": "5m",
|
||||
|
||||
"shutdown_command": "C:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /unattend:A:\\Sysprep_Unattend.xml",
|
||||
"shutdown_timeout": "1h",
|
||||
|
||||
"export": {
|
||||
"images": false,
|
||||
"output_directory": "/scratch/srv2019-v"
|
||||
}
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "windows-update"
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"inline": [
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
|
||||
"Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "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]
|
||||
},
|
||||
{
|
||||
"type": "windows-update"
|
||||
},
|
||||
{
|
||||
"only": ["srv2019-v"],
|
||||
"type": "powershell",
|
||||
"inline": [
|
||||
"New-Item -Path 'C:\\Payload\\Scripts' -ItemType 'Directory' -Force:$True -Confirm:$False"
|
||||
]
|
||||
},
|
||||
{
|
||||
"only": ["srv2019-v"],
|
||||
"type": "file",
|
||||
"source": "scripts/Server2019/payload/",
|
||||
"destination": "C:\\Payload\\"
|
||||
},
|
||||
{
|
||||
"only": ["srv2019-v"],
|
||||
"type": "powershell",
|
||||
"scripts": [
|
||||
"scripts/Server2019/Register-ScheduledTask.ps1"
|
||||
]
|
||||
}
|
||||
],
|
||||
"post-processors": [[
|
||||
{
|
||||
"only": ["srv2019-t"],
|
||||
"type": "vsphere",
|
||||
"host": "{{user `vcenter_server`}}",
|
||||
"username": "{{user `vsphere_username`}}",
|
||||
"password": "{{user `vsphere_password`}}",
|
||||
"insecure": true,
|
||||
"vm_name": "Windows-Server-2019-LTSC",
|
||||
"datacenter": "{{user `vsphere_datacenter`}}",
|
||||
"cluster": "{{user `vsphere_host`}}",
|
||||
"vm_folder": "{{user `vsphere_templatefolder`}}",
|
||||
"datastore": "{{user `vsphere_datastore`}}",
|
||||
"disk_mode": "thin",
|
||||
"vm_network": "{{user `vsphere_network`}}",
|
||||
"overwrite": true,
|
||||
"keep_input_artifact": true
|
||||
},
|
||||
{
|
||||
"only": ["srv2019-t"],
|
||||
"type": "vsphere-template",
|
||||
"host": "{{user `vcenter_server`}}",
|
||||
"username": "{{user `vsphere_username`}}",
|
||||
"password": "{{user `vsphere_password`}}",
|
||||
"insecure": true,
|
||||
"datacenter": "{{user `vsphere_datacenter`}}",
|
||||
"folder": "{{user `vsphere_templatefolder`}}",
|
||||
"reregister_vm": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"only": ["srv2019-v"],
|
||||
"type": "shell-local",
|
||||
"inline": [
|
||||
"cat '/scratch/srv2019-v/{{user `vm_guestos`}}-{{user `vm_name`}}-v.ovf'",
|
||||
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
||||
" -OVFFile '/scratch/srv2019-v/{{user `vm_guestos`}}-{{user `vm_name`}}-v.ovf' \\",
|
||||
" -Parameter @{'appliance.name'='{{user `vm_guestos`}}';'appliance.version'='{{user `vm_name`}}'}\"",
|
||||
"cat '/scratch/srv2019-v/{{user `vm_guestos`}}-{{user `vm_name`}}-v.ovf'",
|
||||
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
||||
" -ManifestFileName '/scratch/srv2019-v/{{user `vm_guestos`}}-{{user `vm_name`}}-v.mf'",
|
||||
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
||||
" '/scratch/srv2019-v/{{user `vm_guestos`}}-{{user `vm_name`}}-v.ovf' \\",
|
||||
" /output/Windows-Server-2019-LTSC.ova"
|
||||
]
|
||||
}
|
||||
]]
|
||||
}
|
@@ -1,23 +1,23 @@
|
||||
packer {
|
||||
required_plugins {
|
||||
windows-update = {
|
||||
version = "0.12.0"
|
||||
version = ">= 0.12.0"
|
||||
source = "github.com/rgl/windows-update"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source "vsphere-iso" "srv2019-t" {
|
||||
vcenter_server = "${var.vcenter_server}"
|
||||
username = "${var.vsphere_username}"
|
||||
password = "${var.vsphere_password}"
|
||||
source "vsphere-iso" "srv2019-template" {
|
||||
vcenter_server = var.vcenter_server
|
||||
username = var.vsphere_username
|
||||
password = var.vsphere_password
|
||||
insecure_connection = "true"
|
||||
|
||||
vm_name = "${var.vm_guestos}-${var.vm_name}-t"
|
||||
datacenter = "${var.vsphere_datacenter}"
|
||||
host = "${var.vsphere_host}"
|
||||
folder = "${var.vsphere_folder}"
|
||||
datastore = "${var.vsphere_datastore}"
|
||||
vm_name = "${var.vm_guestos}-${var.vm_name}-template"
|
||||
datacenter = var.vsphere_datacenter
|
||||
host = var.vsphere_host
|
||||
folder = var.vsphere_folder
|
||||
datastore = var.vsphere_datastore
|
||||
|
||||
guest_os_type = "windows9Server64Guest"
|
||||
|
||||
@@ -27,14 +27,14 @@ source "vsphere-iso" "srv2019-t" {
|
||||
|
||||
communicator = "winrm"
|
||||
winrm_username = "administrator"
|
||||
winrm_password = "${var.winrm_password}"
|
||||
winrm_password = var.winrm_password
|
||||
winrm_timeout = "10m"
|
||||
|
||||
RAM = 8192
|
||||
RAM = 4096
|
||||
CPUs = 2
|
||||
|
||||
network_adapters {
|
||||
network = "${var.vsphere_network}"
|
||||
network = var.vsphere_network
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
storage {
|
||||
@@ -52,50 +52,48 @@ source "vsphere-iso" "srv2019-t" {
|
||||
"scripts/Enable-WinRM.ps1",
|
||||
"scripts/Install-VMwareTools.cmd"
|
||||
]
|
||||
iso_checksum = "sha256:4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d"
|
||||
iso_paths = [
|
||||
"ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
|
||||
]
|
||||
iso_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/iso/Microsoft/Windows%20Server%202019/LTSC/en_windows_server_2019_x64_dvd_4cb967d8.iso"
|
||||
iso_url = local.iso_authenticatedurl
|
||||
iso_checksum = var.iso_checksum
|
||||
iso_paths = var.iso_paths
|
||||
|
||||
shutdown_command = "C:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /unattend:A:\\Sysprep_Unattend.xml"
|
||||
shutdown_timeout = "1h"
|
||||
|
||||
export {
|
||||
images = false
|
||||
output_directory = "/scratch/srv2019-t"
|
||||
output_directory = "/scratch/srv2019-template"
|
||||
}
|
||||
remove_cdrom = true
|
||||
}
|
||||
|
||||
source "vsphere-iso" "srv2019-v" {
|
||||
vcenter_server = "${var.vcenter_server}"
|
||||
username = "${var.vsphere_username}"
|
||||
password = "${var.vsphere_password}"
|
||||
source "vsphere-iso" "srv2019-virtual" {
|
||||
vcenter_server = var.vcenter_server
|
||||
username = var.vsphere_username
|
||||
password = var.vsphere_password
|
||||
insecure_connection = "true"
|
||||
|
||||
vm_name = "${var.vm_guestos}-${var.vm_name}-v"
|
||||
datacenter = "${var.vsphere_datacenter}"
|
||||
host = "${var.vsphere_host}"
|
||||
folder = "${var.vsphere_folder}"
|
||||
datastore = "${var.vsphere_datastore}"
|
||||
vm_name = "${var.vm_guestos}-${var.vm_name}-virtual"
|
||||
datacenter = var.vsphere_datacenter
|
||||
host = var.vsphere_host
|
||||
folder = var.vsphere_folder
|
||||
datastore = var.vsphere_datastore
|
||||
|
||||
guest_os_type = "windows9Server64Guest"
|
||||
|
||||
|
||||
boot_order = "disk,cdrom"
|
||||
boot_command = [""]
|
||||
boot_wait = "5m"
|
||||
|
||||
communicator = "winrm"
|
||||
winrm_password = "${var.winrm_password}"
|
||||
winrm_password = var.winrm_password
|
||||
winrm_timeout = "10m"
|
||||
winrm_username = "administrator"
|
||||
|
||||
RAM = 8192
|
||||
RAM = 4096
|
||||
CPUs = 2
|
||||
|
||||
network_adapters {
|
||||
network = "${var.vsphere_network}"
|
||||
network = var.vsphere_network
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
storage {
|
||||
@@ -113,38 +111,113 @@ source "vsphere-iso" "srv2019-v" {
|
||||
"scripts/Enable-WinRM.ps1",
|
||||
"scripts/Install-VMwareTools.cmd"
|
||||
]
|
||||
iso_checksum = "sha256:4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d"
|
||||
iso_paths = [
|
||||
"ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
|
||||
]
|
||||
iso_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/iso/Microsoft/Windows%20Server%202019/LTSC/en_windows_server_2019_x64_dvd_4cb967d8.iso"
|
||||
iso_url = local.iso_authenticatedurl
|
||||
iso_checksum = var.iso_checksum
|
||||
iso_paths = var.iso_paths
|
||||
|
||||
shutdown_command = "C:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /unattend:A:\\Sysprep_Unattend.xml"
|
||||
shutdown_timeout = "1h"
|
||||
|
||||
export {
|
||||
images = false
|
||||
output_directory = "/scratch/srv2019-v"
|
||||
output_directory = "/scratch/srv2019-virtual"
|
||||
}
|
||||
remove_cdrom = true
|
||||
}
|
||||
|
||||
source "vsphere-iso" "srv2019-baremetal" {
|
||||
vcenter_server = var.vcenter_server
|
||||
username = var.vsphere_username
|
||||
password = var.vsphere_password
|
||||
insecure_connection = "true"
|
||||
|
||||
vm_name = "${var.vm_guestos}-${var.vm_name}-baremetal"
|
||||
datacenter = var.vsphere_datacenter
|
||||
host = var.vsphere_host
|
||||
folder = var.vsphere_folder
|
||||
datastore = var.vsphere_datastore
|
||||
|
||||
guest_os_type = "windows9Server64Guest"
|
||||
|
||||
boot_order = "disk,cdrom"
|
||||
boot_command = [""]
|
||||
boot_wait = "5m"
|
||||
|
||||
communicator = "winrm"
|
||||
winrm_username = "administrator"
|
||||
winrm_password = var.winrm_password
|
||||
winrm_timeout = "10m"
|
||||
|
||||
RAM = 4096
|
||||
CPUs = 2
|
||||
|
||||
network_adapters {
|
||||
network = var.vsphere_network
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
storage {
|
||||
disk_size = 20480
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
disk_controller_type = ["pvscsi"]
|
||||
usb_controller = ["xhci"]
|
||||
|
||||
floppy_files = [
|
||||
"packer/preseed/Server2019/pvscsi/Autounattend.xml",
|
||||
"packer/preseed/Server2019/Sysprep_Unattend.xml",
|
||||
"scripts/Set-NetworkProfile.ps1",
|
||||
"scripts/Disable-WinRM.ps1",
|
||||
"scripts/Enable-WinRM.ps1",
|
||||
"scripts/Install-VMwareTools.cmd"
|
||||
]
|
||||
iso_url = local.iso_authenticatedurl
|
||||
iso_checksum = var.iso_checksum
|
||||
iso_paths = var.iso_paths
|
||||
|
||||
shutdown_command = "C:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /unattend:A:\\Sysprep_Unattend.xml"
|
||||
shutdown_timeout = "1h"
|
||||
|
||||
export {
|
||||
images = false
|
||||
output_directory = "/scratch/srv2019-baremetal"
|
||||
}
|
||||
remove_cdrom = true
|
||||
}
|
||||
|
||||
build {
|
||||
// sources = [
|
||||
// "source.vsphere-iso.srv2019-template",
|
||||
// "source.vsphere-iso.srv2019-virtual",
|
||||
// "source.vsphere-iso.srv2019-baremetal"
|
||||
// ]
|
||||
sources = [
|
||||
"source.vsphere-iso.srv2019-t",
|
||||
"source.vsphere-iso.srv2019-v"
|
||||
"source.vsphere-iso.srv2019-template",
|
||||
"source.vsphere-iso.srv2019-virtual"
|
||||
]
|
||||
|
||||
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" {
|
||||
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",
|
||||
@@ -160,70 +233,81 @@ build {
|
||||
}
|
||||
|
||||
provisioner "powershell" {
|
||||
only = ["srv2019-v"]
|
||||
only = ["vsphere-iso.srv2019-virtual"]
|
||||
inline = [
|
||||
"New-Item -Path 'C:\\Payload\\Scripts' -ItemType 'Directory' -Force:$True -Confirm:$False"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
only = ["srv2019-v"]
|
||||
only = ["vsphere-iso.srv2019-virtual"]
|
||||
destination = "C:\\Payload\\"
|
||||
source = "scripts/Server2019/payload/"
|
||||
source = "scripts/payload/"
|
||||
}
|
||||
|
||||
provisioner "powershell" {
|
||||
only = ["srv2019-v"]
|
||||
only = ["vsphere-iso.srv2019-virtual"]
|
||||
scripts = [
|
||||
"scripts/Server2019/Register-ScheduledTask.ps1"
|
||||
"scripts/Register-ScheduledTask.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
post-processors {
|
||||
post-processor "vsphere" {
|
||||
only = ["srv2019-t"]
|
||||
only = ["vsphere-iso.srv2019-template"]
|
||||
|
||||
host = "${var.vcenter_server}"
|
||||
username = "${var.vsphere_username}"
|
||||
password = "${var.vsphere_password}"
|
||||
host = var.vcenter_server
|
||||
username = var.vsphere_username
|
||||
password = var.vsphere_password
|
||||
insecure = true
|
||||
|
||||
vm_name = "Windows-Server-2019-LTSC"
|
||||
datacenter = "${var.vsphere_datacenter}"
|
||||
cluster = "${var.vsphere_host}"
|
||||
vm_folder = "${var.vsphere_templatefolder}"
|
||||
vm_network = "${var.vsphere_network}"
|
||||
datastore = "${var.vsphere_datastore}"
|
||||
datacenter = var.vsphere_datacenter
|
||||
cluster = var.vsphere_host
|
||||
vm_folder = var.vsphere_templatefolder
|
||||
vm_network = var.vsphere_network
|
||||
datastore = var.vsphere_datastore
|
||||
disk_mode = "thin"
|
||||
|
||||
keep_input_artifact = true
|
||||
overwrite = true
|
||||
}
|
||||
post-processor "vsphere-template" {
|
||||
only = ["srv2019-t"]
|
||||
only = ["vsphere-iso.srv2019-template"]
|
||||
|
||||
host = "${var.vcenter_server}"
|
||||
username = "${var.vsphere_username}"
|
||||
password = "${var.vsphere_password}"
|
||||
host = var.vcenter_server
|
||||
username = var.vsphere_username
|
||||
password = var.vsphere_password
|
||||
insecure = true
|
||||
|
||||
datacenter = "${var.vsphere_datacenter}"
|
||||
folder = "${var.vsphere_templatefolder}"
|
||||
datacenter = var.vsphere_datacenter
|
||||
folder = var.vsphere_templatefolder
|
||||
|
||||
reregister_vm = false
|
||||
}
|
||||
}
|
||||
post-processor "shell-local" {
|
||||
only = ["srv2019-v"]
|
||||
only = ["vsphere-iso.srv2019-virtual"]
|
||||
inline = [
|
||||
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
||||
" -OVFFile '/scratch/srv2019-v/${var.vm_guestos}-${var.vm_name}-v.ovf' \\",
|
||||
" -OVFFile '/scratch/srv2019-virtual/${var.vm_guestos}-${var.vm_name}-virtual.ovf' \\",
|
||||
" -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"",
|
||||
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
||||
" -ManifestFileName '/scratch/srv2019-v/${var.vm_guestos}-${var.vm_name}-v.mf'",
|
||||
" -ManifestFileName '/scratch/srv2019-virtual/${var.vm_guestos}-${var.vm_name}-virtual.mf'",
|
||||
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
||||
" '/scratch/srv2019-v/${var.vm_guestos}-${var.vm_name}-v.ovf' \\",
|
||||
" '/scratch/srv2019-virtual/${var.vm_guestos}-${var.vm_name}-virtual.ovf' \\",
|
||||
" /output/Windows-Server-2019-LTSC.ova"
|
||||
]
|
||||
}
|
||||
post-processor "shell-local" {
|
||||
only = ["vsphere-iso.srv2019-baremetal"]
|
||||
inline = [
|
||||
"qemu-img convert -f vmdk -O raw \\",
|
||||
" /scratch/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}-baremetal-disk-0.vmdk \\",
|
||||
" /tmp/${var.vm_guestos}-${var.vm_name}.raw",
|
||||
"gzip -c \\",
|
||||
" /tmp/${var.vm_guestos}-${var.vm_name}.raw \\",
|
||||
" > /output/Windows-Server-2019-LTSC.raw.gz"
|
||||
]
|
||||
}
|
||||
}
|
40
scripts/Install-Prerequisites.ps1
Normal file
40
scripts/Install-Prerequisites.ps1
Normal 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
|
||||
}
|
||||
}
|
74
scripts/Install-WinGet.ps1
Normal file
74
scripts/Install-WinGet.ps1
Normal file
@@ -0,0 +1,74 @@
|
||||
#Requires -Modules 'NtObjectManager'
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
# 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 = @{
|
||||
Uri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
|
||||
Method = 'GET'
|
||||
}
|
||||
$LatestRelease = Invoke-RestMethod @InvokeRestMethodSplat
|
||||
$InvokeWebRequestSplat = @{
|
||||
Uri = ($LatestRelease.assets | Where-Object {$_.name -like '*.msixbundle'}).browser_download_url
|
||||
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
|
||||
|
||||
# Install dependencies
|
||||
$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"
|
Reference in New Issue
Block a user