Update netplan config in Ubuntu 18.04 with Terraform

381 views
Skip to first unread message

Steven Stratis

unread,
Mar 4, 2019, 6:47:34 PM3/4/19
to Terraform
Hi

I'm using Terraform and the vSphere provider to spin up VMs based on ubuntu 18.04 templates I created with packer. When the VMs spin up they are being given IP addresses from dhcp. I would prefer to spin them up with specific private IP address though, I've read through a couple of the github issues where people have reported issues with this. Using `network_interface` in the customize block of my resource declaration of the VM doesn't seem to have any effect. 

Is there a common approach to updating netplan configurations when using terraform to build up vmware virtual machines? Here is an example of one of my resoure blocks. Thanks for any help!

resource "vsphere_virtual_machine" "kube_worker_3" {
resource_pool_id = "${data.vsphere_resource_pool.pool.id}"
name = "kube-worker-3"
folder = "${var.vsphere_vm_folder}"

enable_disk_uuid = true
wait_for_guest_net_timeout = 0

num_cpus = 4
memory = 4096
guest_id = "ubuntu64Guest"
scsi_type = "pvscsi"
#scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}"

network_interface {
}

disk {
label = "kube-worker-3-disk"
size = 60
}

clone {

customize {
timeout = 0

linux_options {
host_name = "kube-worker-3"
domain = "${var.vsphere_host}.local"
}
network_interface {
ipv4_address = "192.168.0.27"
ipv4_netmask = "24"
}
ipv4_gateway = "192.168.0.1"
}
}
}
Reply all
Reply to author
Forward
0 new messages