I have a module I created to create an Ubuntu server on Esxi. Within the resource, I have a connection and a remote-exec provisioner. When I had these in the root module for testing, all worked well. Creating the same resource in a module, it fails with a message that the connection host cannot be empty.
Below is a small snippet of my code for the resourse.
resource "esxi_guest" "Default" {
guest_name = var.guest_name
...
connection {
type = "ssh"
user = "mark"
password = var.vm_password
host = self.ip_address
}
provisioner "remote-exec" {
inline = [
"sudo growpart /dev/sda 1",
"sudo resize2fs /dev/sda1"
]
}
}
If self does not work, how can I obtain the assigned IP address?