Move iso details to separate file;Add baremetal builder/source
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Danny Bessems 2021-06-21 09:28:22 +02:00
parent 1e699d62a2
commit 1459e6dead
3 changed files with 108 additions and 28 deletions

View 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"
]

View File

@ -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
}

View File

@ -7,13 +7,13 @@ packer {
}
}
source "vsphere-iso" "srv2019-t" {
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"
vm_name = "${var.vm_guestos}-${var.vm_name}-template"
datacenter = var.vsphere_datacenter
host = var.vsphere_host
folder = var.vsphere_folder
@ -52,36 +52,34 @@ 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" {
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"
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"
@ -113,26 +111,84 @@ 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 = 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_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-t",
"source.vsphere-iso.srv2019-v"
"source.vsphere-iso.srv2019-template",
"source.vsphere-iso.srv2019-virtual",
"source.vsphere-iso.srv2019-baremetal"
]
provisioner "windows-update" {
@ -160,20 +216,20 @@ build {
}
provisioner "powershell" {
only = ["vsphere-iso.srv2019-v"]
only = ["vsphere-iso.srv2019-virtual"]
inline = [
"New-Item -Path 'C:\\Payload\\Scripts' -ItemType 'Directory' -Force:$True -Confirm:$False"
]
}
provisioner "file" {
only = ["vsphere-iso.srv2019-v"]
only = ["vsphere-iso.srv2019-virtual"]
destination = "C:\\Payload\\"
source = "scripts/Server2019/payload/"
}
provisioner "powershell" {
only = ["vsphere-iso.srv2019-v"]
only = ["vsphere-iso.srv2019-virtual"]
scripts = [
"scripts/Server2019/Register-ScheduledTask.ps1"
]
@ -181,7 +237,7 @@ build {
post-processors {
post-processor "vsphere" {
only = ["vsphere-iso.srv2019-t"]
only = ["vsphere-iso.srv2019-template"]
host = var.vcenter_server
username = var.vsphere_username
@ -200,7 +256,7 @@ build {
overwrite = true
}
post-processor "vsphere-template" {
only = ["vsphere-iso.srv2019-t"]
only = ["vsphere-iso.srv2019-template"]
host = var.vcenter_server
username = var.vsphere_username
@ -214,16 +270,27 @@ build {
}
}
post-processor "shell-local" {
only = ["vsphere-iso.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}-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'",
" -ManifestFileName '/scratch/srv2019-virtual/${var.vm_guestos}-${var.vm_name}-v.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}-v.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 \\",
" /scratch/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}.raw",
"gzip -c \\",
" /scratch/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}.raw \\",
" > /output/Windows-Server-2019-LTSC.raw.gz"
]
}
}