Following…
https://github.com/josenk/terraform-provider-esxi/tree/master/examples/01%20Simple%20Guest

> ls -l
total 4
-rwxrwxrwx 1 root root 977 Jan 28 01:12 main.tf
-rwxrwxrwx 1 root root 180 Jan 28 01:15 terraform.tfstate
-rwxrwxrwx 1 root root 417 Jan 28 01:15 variables.tf
-rwxrwxrwx 1 root root 353 Jan 28 01:10 versions.tf
> cat main.tf
#########################################
#  ESXI Provider host/login details
#########################################
#
#   Use of variables here to hide/move the variables to a separate file
#
provider "esxi" {
  esxi_hostname = var.esxi_hostname
  esxi_hostport = var.esxi_hostport
  esxi_hostssl  = var.esxi_hostssl
  esxi_username = var.esxi_username
  esxi_password = var.esxi_password
}

#########################################
#  ESXI Guest resource
#########################################
#
#  This Guest VM is "bare-metal".   It will be powered on by default
#  by terraform, but it will not boot to any OS.   It will however attempt
#  to network boot.
#
resource "esxi_guest" "vmtest01" {
  guest_name = "vmtest01" # Required, Specify the Guest Name
  disk_store = "datastore1"   # Required, Specify an existing Disk Store
  network_interfaces {
    virtual_network = "VM Network" # Required for each network interface, Specify the Virtual Network name.
  }
}
> cat versions.tf
terraform {
  required_version = ">= 0.13"
  required_providers {
    esxi = {
      source = "registry.terraform.io/josenk/esxi"
      #
      # For more information, see the provider source documentation:
      #
      # https://github.com/josenk/terraform-provider-esxi
      # https://registry.terraform.io/providers/josenk/esxi
      #
    }
  }
}
> cat variables.tf
#
#  See https://www.terraform.io/intro/getting-started/variables.html for more details.
#

#  Change these defaults to fit your needs!

variable "esxi_hostname" {
  default = "192.168.XX.XX"
}

variable "esxi_hostport" {
  default = "22"
}

variable "esxi_hostssl" {
  default = "443"
}

variable "esxi_username" {
  default = "root"
}

variable "esxi_password" { # Unspecified will prompt
  default = "******"
}
> terraform plan

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # esxi_guest.vmtest01 will be created
  + resource "esxi_guest" "vmtest01" {
      + boot_disk_size         = (known after apply)
      + boot_disk_type         = "thin"
      + boot_firmware          = "bios"
      + disk_store             = "datastore1"
      + guest_name             = "vmtest01"
      + guest_shutdown_timeout = (known after apply)
      + guest_startup_timeout  = (known after apply)
      + guestos                = (known after apply)
      + id                     = (known after apply)
      + ip_address             = (known after apply)
      + memsize                = (known after apply)
      + notes                  = (known after apply)
      + numvcpus               = (known after apply)
      + ovf_properties_timer   = (known after apply)
      + power                  = (known after apply)
      + resource_pool_name     = "/"
      + virthwver              = (known after apply)

      + network_interfaces {
          + mac_address     = (known after apply)
          + nic_type        = (known after apply)
          + virtual_network = "VM Network"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
> terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # esxi_guest.vmtest01 will be created
  + resource "esxi_guest" "vmtest01" {
      + boot_disk_size         = (known after apply)
      + boot_disk_type         = "thin"
      + boot_firmware          = "bios"
      + disk_store             = "datastore1"
      + guest_name             = "vmtest01"
      + guest_shutdown_timeout = (known after apply)
      + guest_startup_timeout  = (known after apply)
      + guestos                = (known after apply)
      + id                     = (known after apply)
      + ip_address             = (known after apply)
      + memsize                = (known after apply)
      + notes                  = (known after apply)
      + numvcpus               = (known after apply)
      + ovf_properties_timer   = (known after apply)
      + power                  = (known after apply)
      + resource_pool_name     = "/"
      + virthwver              = (known after apply)

      + network_interfaces {
          + mac_address     = (known after apply)
          + nic_type        = (known after apply)
          + virtual_network = "VM Network"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

esxi_guest.vmtest01: Creating...
â•·
│ Error: Failed to grow boot disk: Process exited with status 255
│
│
│   with esxi_guest.vmtest01,
│   on main.tf line 23, in resource "esxi_guest" "vmtest01":
│   23: resource "esxi_guest" "vmtest01" {
│
╵
https://github.com/josenk/terraform-provider-esxi/issues/172
Just my luck! – Time to consider Proxmox ??

Leave a Reply