Skip to content

Instantly share code, notes, and snippets.

@jonchen727
Created July 21, 2021 15:52
Show Gist options
  • Save jonchen727/6f7a0b3d276f64e50d3fa928b8df8f7d to your computer and use it in GitHub Desktop.
Save jonchen727/6f7a0b3d276f64e50d3fa928b8df8f7d to your computer and use it in GitHub Desktop.
deploy ubuntu 20.04 to vsphere and prep for terraform static ip assignment
source “vsphere-iso” “this” {
vcenter_server = var.vsphere_server
username = var.vsphere_user
password = var.vsphere_password
datacenter = var.datacenter
cluster = var.cluster
insecure_connection = true
vm_name = “tf-ubuntu-server-20.04”
guest_os_type = “ubuntu64Guest”
ssh_username = “ubuntu”
ssh_password = “ubuntu”
ssh_timeout = “20m”
ssh_handshake_attempts = “50”
CPUs = 8
RAM = 4128
RAM_reserve_all = true
disk_controller_type = [“pvscsi”]
datastore = var.datastore
storage {
disk_size = 16384
disk_thin_provisioned = true
}
iso_paths = [“[iSCSI Raid-10] OS/ubuntu-20.04.2-live-server-amd64.iso”]
iso_checksum = “sha256:b23488689e16cad7a269eb2d3a3bf725d3457ee6b0868e00c8762d3816e25848”
http_directory = “subiquity/http”
http_port_max = 8336
http_port_min = 8336
network_adapters {
network = var.network_name
network_card = “vmxnet3”
}
boot_wait = “5s”
boot_command = [
” “,
“autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds=nocloud-net;seedfrom=http://192.168.0.168:{{ .HTTPPort }}/”,
“”
]
}
build {
sources = [
“source.vsphere-iso.this”
]
provisioner “shell” {
inline = [
“while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 5; done”,
“sudo rm /etc/netplan/*”,
“sudo sed -i ‘s/ip=dhcp//g’ /etc/default/grub”,
“sudo update-grub”,
“sudo apt -y purge cloud-init”
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment