Hi
I’m new to terraform and I’m running an ESXi lab and want to install 3 linux boxes based on the provider (josenk/esxi).
My main.tf works basically for one instance:
resource “esxi_guest” “Linux” {
guest_name = “vmtest”
disk_store = “datastore”
boot_disk_size = “30”
memsize = “3072”
numvcpus = “1”
power = “on”
guestos = “ubuntu-64”
network_interfaces {
virtual_network = “VM Network”
}
}
But how do I create dynamically 3 boxes based on that resource?
I red there must be something done based on modules.
Can anyone explain how to do this?
Any help kindly appreciated!
ndee
I figured out myself how to achieve this for free ESXi system.
It is basically very simple:
locals {
guests = {
“u-k8s-m1” = { },
“u-k8s-n1” = { },
“u-k8s-n2” = { }
}
}
resource “esxi_guest” “Linux” {
for_each = local.guests
guest_name = each.key
disk_store = “datastore”
boot_disk_size = “30”
memsize = “3072”
numvcpus = “1”
power = “off”
guestos = “ubuntu-64”
network_interfaces {
virtual_network = “VM Network”
}
}
I hope it helps others in case.
cheers
1 Like
@aracloud Could you please provide what have you inserted as a esxi_hostname, username and password? How did you find these values?