2021-06-07 11:19:00 +00:00
|
|
|
packer {
|
|
|
|
required_plugins {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-24 21:44:10 +00:00
|
|
|
source "vsphere-iso" "k8sbootstrap" {
|
2021-06-07 11:19:00 +00:00
|
|
|
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
|
2022-04-25 07:21:05 +00:00
|
|
|
cluster = var.vsphere_cluster
|
2021-06-07 11:19:00 +00:00
|
|
|
host = var.vsphere_host
|
|
|
|
folder = var.vsphere_folder
|
|
|
|
datastore = var.vsphere_datastore
|
|
|
|
|
|
|
|
guest_os_type = "ubuntu64Guest"
|
2021-06-17 09:21:22 +00:00
|
|
|
|
2021-06-07 11:19:00 +00:00
|
|
|
boot_order = "disk,cdrom"
|
|
|
|
boot_command = [
|
2022-06-22 09:40:25 +00:00
|
|
|
"e<down><down><down><end>",
|
|
|
|
" autoinstall ds=nocloud;",
|
|
|
|
"<F10>"
|
2021-06-07 11:19:00 +00:00
|
|
|
]
|
|
|
|
boot_wait = "2s"
|
2021-06-17 09:21:22 +00:00
|
|
|
|
2021-06-07 11:19:00 +00:00
|
|
|
communicator = "ssh"
|
2021-06-07 12:54:22 +00:00
|
|
|
ssh_username = "ubuntu"
|
2021-06-08 07:24:39 +00:00
|
|
|
ssh_password = var.ssh_password
|
2021-06-07 12:54:22 +00:00
|
|
|
ssh_timeout = "20m"
|
|
|
|
ssh_handshake_attempts = "100"
|
|
|
|
ssh_pty = true
|
2021-06-17 09:21:22 +00:00
|
|
|
|
2021-06-07 11:19:00 +00:00
|
|
|
CPUs = 2
|
|
|
|
RAM = 4096
|
2021-06-17 09:21:22 +00:00
|
|
|
|
2021-06-07 11:19:00 +00:00
|
|
|
network_adapters {
|
|
|
|
network = var.vsphere_network
|
|
|
|
network_card = "vmxnet3"
|
|
|
|
}
|
|
|
|
storage {
|
2022-06-27 14:02:11 +00:00
|
|
|
disk_size = 51200
|
2021-06-07 11:19:00 +00:00
|
|
|
disk_thin_provisioned = true
|
|
|
|
}
|
|
|
|
disk_controller_type = ["pvscsi"]
|
|
|
|
usb_controller = ["xhci"]
|
|
|
|
|
|
|
|
cd_files = [
|
2022-06-22 09:40:25 +00:00
|
|
|
"packer/preseed/UbuntuServer22.04/user-data",
|
|
|
|
"packer/preseed/UbuntuServer22.04/meta-data"
|
2021-06-07 11:19:00 +00:00
|
|
|
]
|
|
|
|
cd_label = "cidata"
|
2021-06-10 09:53:51 +00:00
|
|
|
iso_url = local.iso_authenticatedurl
|
2021-06-10 09:39:42 +00:00
|
|
|
iso_checksum = var.iso_checksum
|
2021-06-07 11:19:00 +00:00
|
|
|
|
|
|
|
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now"
|
|
|
|
shutdown_timeout = "5m"
|
|
|
|
|
|
|
|
export {
|
|
|
|
images = false
|
2022-06-24 22:50:44 +00:00
|
|
|
output_directory = "/scratch/k8sbootstrap"
|
2021-06-07 11:19:00 +00:00
|
|
|
}
|
|
|
|
remove_cdrom = true
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
2021-06-17 09:21:22 +00:00
|
|
|
sources = [
|
2022-06-24 21:44:10 +00:00
|
|
|
"source.vsphere-iso.k8sbootstrap"
|
2021-06-17 09:21:22 +00:00
|
|
|
]
|
2021-06-07 11:19:00 +00:00
|
|
|
|
2021-06-08 07:24:39 +00:00
|
|
|
provisioner "ansible" {
|
2022-06-26 16:48:06 +00:00
|
|
|
pause_before = "2m30s"
|
2021-06-17 09:21:22 +00:00
|
|
|
|
2021-06-08 08:41:01 +00:00
|
|
|
playbook_file = "ansible/playbook.yml"
|
|
|
|
user = "ubuntu"
|
|
|
|
ansible_env_vars = [
|
|
|
|
"ANSIBLE_CONFIG=ansible/ansible.cfg"
|
|
|
|
]
|
2021-06-08 13:26:41 +00:00
|
|
|
use_proxy = "false"
|
2021-06-08 11:51:22 +00:00
|
|
|
extra_arguments = [
|
2022-07-27 11:33:04 +00:00
|
|
|
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}",
|
|
|
|
"--extra-vars", "repo_username=${var.repo_username}",
|
|
|
|
"--extra-vars", "repo_password=${var.repo_password}"
|
2021-06-08 11:51:22 +00:00
|
|
|
]
|
2021-06-08 07:24:39 +00:00
|
|
|
}
|
2021-06-07 11:19:00 +00:00
|
|
|
|
|
|
|
post-processor "shell-local" {
|
|
|
|
inline = [
|
|
|
|
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
2022-06-24 21:44:10 +00:00
|
|
|
" -OVFFile '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
2021-06-07 11:19:00 +00:00
|
|
|
" -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"",
|
|
|
|
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
2022-06-24 21:44:10 +00:00
|
|
|
" -ManifestFileName '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.mf'",
|
2021-06-07 11:19:00 +00:00
|
|
|
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
2022-06-24 21:44:10 +00:00
|
|
|
" '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
|
|
|
" /output/Kubernetes.Bootstrap.Appliance.ova"
|
2021-06-07 11:19:00 +00:00
|
|
|
]
|
|
|
|
}
|
2022-06-22 09:40:25 +00:00
|
|
|
}
|