packer { required_plugins { } } source "vsphere-iso" "ubuntuserver" { vcenter_server = var.vcenter_server username = var.vsphere_username password = var.vsphere_password insecure_connection = "true" vm_name = "${var.vm_guestos}-${var.vm_name}" datacenter = var.vsphere_datacenter host = var.vsphere_host folder = var.vsphere_folder datastore = var.vsphere_datastore guest_os_type = "ubuntu64Guest" boot_order = "disk,cdrom" boot_command = [ "", " autoinstall ds=nocloud;", "" ] boot_wait = "2s" communicator = "ssh" ssh_username = "root" ssh_password = var.ssh_password ssh_timeout = "10m" CPUs = 2 RAM = 4096 network_adapters { network = var.vsphere_network network_card = "vmxnet3" } storage { disk_size = 20480 disk_thin_provisioned = true } disk_controller_type = ["pvscsi"] usb_controller = ["xhci"] cd_files = [ "packer/preseed/UbuntuServer20.04/user-data", "packer/preseed/UbuntuServer20.04/meta-data" ] cd_label = "cidata" iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423" iso_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso" shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now" shutdown_timeout = "5m" export { images = false output_directory = "/scratch/ubuntuserver" } remove_cdrom = true } build { sources = ["source.vsphere-iso.ubuntuserver"] // provisioner "file" { // destination = "" // source = "" // } post-processor "shell-local" { inline = [ "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\", " -OVFFile '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", " -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"", "pwsh -file scripts/Update-Manifest.ps1 \\", " -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", " '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", " /output/UbuntuServer20.04.ova" ] } }