Migrate to .hcl;Add new packer init step
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
22f7a433f7
commit
b3e7070f6e
@ -21,27 +21,28 @@ steps:
|
||||
packer/preseed/Server2019/Sysprep_Unattend.xml
|
||||
- |
|
||||
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" scripts
|
||||
- |
|
||||
packer init -upgrade \
|
||||
./packer
|
||||
- |
|
||||
packer validate \
|
||||
-var-file=packer/variables.vsphere.json \
|
||||
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
||||
-var vm_guestos=server2019 \
|
||||
-var repo_username=$${REPO_USERNAME} \
|
||||
-var repo_password=$${REPO_PASSWORD} \
|
||||
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
||||
-var winrm_password=$${WINRM_PASSWORD} \
|
||||
packer/windowsserver2019.json
|
||||
./packer
|
||||
- |
|
||||
packer build \
|
||||
-on-error=cleanup -timestamp-ui \
|
||||
-var-file=packer/variables.vsphere.json \
|
||||
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
||||
-var vm_guestos=server2019 \
|
||||
-var repo_username=$${REPO_USERNAME} \
|
||||
-var repo_password=$${REPO_PASSWORD} \
|
||||
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
||||
-var winrm_password=$${WINRM_PASSWORD} \
|
||||
packer/windowsserver2019.json
|
||||
./packer
|
||||
environment:
|
||||
VSPHERE_PASSWORD:
|
||||
from_secret: vsphere_password
|
||||
|
9
packer/vsphere.auto.pkrvars.hcl
Normal file
9
packer/vsphere.auto.pkrvars.hcl
Normal file
@ -0,0 +1,9 @@
|
||||
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"
|
229
packer/windowsserver2019.pkr.hcl
Normal file
229
packer/windowsserver2019.pkr.hcl
Normal file
@ -0,0 +1,229 @@
|
||||
packer {
|
||||
required_plugins {
|
||||
windows-update = {
|
||||
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}"
|
||||
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}"
|
||||
|
||||
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 = 8192
|
||||
cpus = 2
|
||||
|
||||
network_adapters {
|
||||
network = "${var.vsphere_network}"
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
storage {
|
||||
disk_size = 20480
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
disk_controller_type = "lsilogic-sas"
|
||||
usb_controller = "xhci"
|
||||
|
||||
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"
|
||||
]
|
||||
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"
|
||||
|
||||
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"
|
||||
}
|
||||
remove_cdrom = true
|
||||
}
|
||||
|
||||
source "vsphere-iso" "srv2019-v" {
|
||||
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}"
|
||||
|
||||
guest_os_type = "windows9Server64Guest"
|
||||
|
||||
boot_order = "disk,cdrom"
|
||||
boot_command = ""
|
||||
boot_wait = "5m"
|
||||
|
||||
communicator = "winrm"
|
||||
winrm_password = "${var.winrm_password}"
|
||||
winrm_timeout = "10m"
|
||||
winrm_username = "administrator"
|
||||
|
||||
RAM = 8192
|
||||
cpus = 2
|
||||
|
||||
network_adapters {
|
||||
network = "${var.vsphere_network}"
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
storage {
|
||||
disk_size = 20480
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
disk_controller_type = "lsilogic-sas"
|
||||
usb_controller = "xhci"
|
||||
|
||||
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"
|
||||
]
|
||||
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"
|
||||
|
||||
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"
|
||||
}
|
||||
remove_cdrom = true
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.vsphere-iso.srv2019-t",
|
||||
"source.vsphere-iso.srv2019-v"
|
||||
]
|
||||
|
||||
provisioner "windows-update" {
|
||||
}
|
||||
|
||||
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 "powershell" {
|
||||
only = ["srv2019-v"]
|
||||
inline = [
|
||||
"New-Item -Path 'C:\\Payload\\Scripts' -ItemType 'Directory' -Force:$True -Confirm:$False"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
only = ["srv2019-v"]
|
||||
destination = "C:\\Payload\\"
|
||||
source = "scripts/Server2019/payload/"
|
||||
}
|
||||
|
||||
provisioner "powershell" {
|
||||
only = ["srv2019-v"]
|
||||
scripts = [
|
||||
"scripts/Server2019/Register-ScheduledTask.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
post-processors {
|
||||
post-processor "vsphere" {
|
||||
only = ["srv2019-t"]
|
||||
|
||||
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}"
|
||||
disk_mode = "thin"
|
||||
|
||||
keep_input_artifact = true
|
||||
overwrite = true
|
||||
}
|
||||
post-processor "vsphere-template" {
|
||||
only = ["srv2019-t"]
|
||||
|
||||
host = "${var.vcenter_server}"
|
||||
username = "${var.vsphere_username}"
|
||||
password = "${var.vsphere_password}"
|
||||
insecure = true
|
||||
|
||||
datacenter = "${var.vsphere_datacenter}"
|
||||
folder = "${var.vsphere_templatefolder}"
|
||||
|
||||
reregister_vm = false
|
||||
}
|
||||
}
|
||||
post-processor "shell-local" {
|
||||
only = ["srv2019-v"]
|
||||
inline = [
|
||||
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
||||
" -OVFFile '/scratch/srv2019-v/${var.vm_guestos}-${var.vm_name}-v.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'",
|
||||
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
||||
" '/scratch/srv2019-v/${var.vm_guestos}-${var.vm_name}-v.ovf' \\",
|
||||
" /output/Windows-Server-2019-LTSC.ova"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user