2021-02-26 12:20:15 +00:00
|
|
|
resource "vsphere_virtual_machine" "worker" {
|
|
|
|
for_each = {
|
|
|
|
for name, machine in var.machines :
|
|
|
|
name => machine
|
|
|
|
if machine.node_type == "worker"
|
|
|
|
}
|
|
|
|
|
2021-11-12 19:40:29 +00:00
|
|
|
name = "${var.prefix}-${each.key}"
|
|
|
|
|
2021-02-26 12:20:15 +00:00
|
|
|
resource_pool_id = var.pool_id
|
|
|
|
datastore_id = var.datastore_id
|
|
|
|
|
|
|
|
num_cpus = var.worker_cores
|
|
|
|
memory = var.worker_memory
|
|
|
|
memory_reservation = var.worker_memory
|
|
|
|
guest_id = var.guest_id
|
2021-11-12 19:40:29 +00:00
|
|
|
enable_disk_uuid = "true" # needed for CSI provider
|
2021-02-26 12:20:15 +00:00
|
|
|
scsi_type = var.scsi_type
|
|
|
|
folder = var.folder
|
|
|
|
firmware = var.firmware
|
|
|
|
hardware_version = var.hardware_version
|
|
|
|
|
|
|
|
wait_for_guest_net_routable = false
|
2021-11-12 19:40:29 +00:00
|
|
|
wait_for_guest_net_timeout = 0
|
2021-02-26 12:20:15 +00:00
|
|
|
|
|
|
|
network_interface {
|
|
|
|
network_id = var.network_id
|
|
|
|
adapter_type = var.adapter_type
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
|
|
label = "disk0"
|
|
|
|
size = var.worker_disk_size
|
|
|
|
thin_provisioned = var.disk_thin_provisioned
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [disk]
|
|
|
|
}
|
|
|
|
|
|
|
|
clone {
|
|
|
|
template_uuid = var.template_id
|
|
|
|
}
|
|
|
|
|
|
|
|
cdrom {
|
|
|
|
client_device = true
|
|
|
|
}
|
|
|
|
|
|
|
|
vapp {
|
|
|
|
properties = {
|
|
|
|
"user-data" = base64encode(templatefile("${path.module}/templates/cloud-init.tmpl", { ip = each.value.ip,
|
2021-11-12 19:40:29 +00:00
|
|
|
netmask = each.value.netmask,
|
2021-02-26 12:20:15 +00:00
|
|
|
gw = var.gateway,
|
|
|
|
dns = var.dns_primary,
|
|
|
|
ssh_public_keys = var.ssh_public_keys}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "vsphere_virtual_machine" "master" {
|
|
|
|
for_each = {
|
|
|
|
for name, machine in var.machines :
|
|
|
|
name => machine
|
|
|
|
if machine.node_type == "master"
|
|
|
|
}
|
|
|
|
|
2021-11-12 19:40:29 +00:00
|
|
|
name = "${var.prefix}-${each.key}"
|
|
|
|
|
2021-02-26 12:20:15 +00:00
|
|
|
resource_pool_id = var.pool_id
|
|
|
|
datastore_id = var.datastore_id
|
|
|
|
|
|
|
|
num_cpus = var.master_cores
|
|
|
|
memory = var.master_memory
|
|
|
|
memory_reservation = var.master_memory
|
|
|
|
guest_id = var.guest_id
|
2021-11-12 19:40:29 +00:00
|
|
|
enable_disk_uuid = "true" # needed for CSI provider
|
2021-02-26 12:20:15 +00:00
|
|
|
scsi_type = var.scsi_type
|
|
|
|
folder = var.folder
|
|
|
|
firmware = var.firmware
|
|
|
|
hardware_version = var.hardware_version
|
|
|
|
|
2021-11-12 19:40:29 +00:00
|
|
|
wait_for_guest_net_routable = false
|
|
|
|
wait_for_guest_net_timeout = 0
|
|
|
|
|
2021-02-26 12:20:15 +00:00
|
|
|
network_interface {
|
|
|
|
network_id = var.network_id
|
|
|
|
adapter_type = var.adapter_type
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
|
|
label = "disk0"
|
|
|
|
size = var.master_disk_size
|
|
|
|
thin_provisioned = var.disk_thin_provisioned
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [disk]
|
|
|
|
}
|
|
|
|
|
|
|
|
clone {
|
|
|
|
template_uuid = var.template_id
|
|
|
|
}
|
|
|
|
|
|
|
|
cdrom {
|
|
|
|
client_device = true
|
|
|
|
}
|
|
|
|
|
|
|
|
vapp {
|
|
|
|
properties = {
|
|
|
|
"user-data" = base64encode(templatefile("${path.module}/templates/cloud-init.tmpl", { ip = each.value.ip,
|
2021-11-12 19:40:29 +00:00
|
|
|
netmask = each.value.netmask,
|
2021-02-26 12:20:15 +00:00
|
|
|
gw = var.gateway,
|
|
|
|
dns = var.dns_primary,
|
|
|
|
ssh_public_keys = var.ssh_public_keys}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|