I'm having a really difficult time trying to deploy a CoreOS virtual machine on vsphere using Terraform.
So far this is the terraform file I'm using:
# Configure the VMware vSphere Provider. ENV Variables set for Username and Passwd.
provider "vsphere" {
vsphere_server = "192.168.105.10"
allow_unverified_ssl = true
}
provider "ignition" {
version = "1.0.0"
}
data "vsphere_datacenter" "dc" {
name = "Datacenter"
}
data "vsphere_datastore" "datastore" {
name = "vol_af01_idvms"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
data "vsphere_resource_pool" "pool" {
name = "Cluster_rnd/Resources"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
data "vsphere_network" "network" {
name = "VM Network"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
data "vsphere_virtual_machine" "template" {
name = "coreos_production"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
# Create a folder
resource "vsphere_folder" "TestPath" {
datacenter_id = "${data.vsphere_datacenter.dc.id}"
path = "Test"
type = "vm"
}
#Define ignition data
data "ignition_networkd_unit" "vmnetwork" {
name = "00-ens192.network"
content = <<EOF
[Match]
Name=ens192
[Network]
DNS=8.8.8.8
Address=192.168.105.27/24
Gateway=192.168.105.1
EOF
}
data "ignition_config" "node" {
networkd = [
"${data.ignition_networkd_unit.vmnetwork.id}"
]
}
# Define the VM resource
resource "vsphere_virtual_machine" "vm" {
name = "terraform-test"
folder = "${vsphere_folder.TestPath.path}"
resource_pool_id = "${data.vsphere_resource_pool.pool.id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
num_cpus = 2
memory = 1024
guest_id = "other26xLinux64Guest"
network_interface {
network_id = "${data.vsphere_network.network.id}"
}
disk {
name = "terraform-test.vmdk"
size = "${data.vsphere_virtual_machine.template.disks.0.size}"
eagerly_scrub = "${data.vsphere_virtual_machine.template.disks.0.eagerly_scrub}"
thin_provisioned = "${data.vsphere_virtual_machine.template.disks.0.thin_provisioned}"
}
clone {
template_uuid = "${data.vsphere_virtual_machine.template.id}"
}
extra_config {
guestinfo.coreos.config.data.encoding = "base64"
guestinfo.coreos.config.data = "${base64encode(data.ignition_config.node.rendered)}"
}
}
I'm using terraform vsphere provier to create the virtual machine and ignition provider to pass customization details of the virtual machine such as network configuration.
It is not quite clear to me if I'm using correctly the extra_config property on the virtual machine definition. You can find documentation about that property here.
Virtual machine gets created, but network settings never are applied, meaning that ignition provisioning is not correctly working.
I would appreciate any guidance on how to properly configure Terraform for this particular scenario (Vsphere environment and CoreOS virtual machine), specially regarding guestinfo configuration.
Terraform v0.11.1, provider.ignition v1.0.0, provider.vsphere v1.1.0
VMware ESXi, 6.5.0, 5310538
CoreOS 1520.0.0