josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
540 stars 154 forks source link

VMDK creation fails when datastore name contains spaces #139

Closed stephan2012 closed 3 years ago

stephan2012 commented 3 years ago

Describe the bug Creating a guest with a VMDK fails when the datastore name contains spaces. Looks like a quoting issue.

See output below.

To Reproduce Steps to reproduce the behavior:

  1. Create a VM and set disk_store to a datastore that contains at least one space character
  2. Run terraform apply

Expected behavior Any valid datastore name should be accepted.

Terraform files


resource "esxi_guest" "backup_appliance" {
  guest_name         = "asa-backup"
  disk_store         = "SSD Home"
  boot_disk_type     = "zeroedthick"
  boot_disk_size     = 10
  guestos            = "ubuntu-64"
  memsize            = 4096
  numvcpus           = 4
  virthwver          = 15
  power              = "off"

  #
  #  Specify an existing guest to clone, an ovf source, or neither to build a bare-metal guest vm.
  #
  #clone_from_vm      = "Templates/centos7"
  #ovf_source        = "/local_path/centos-7.vmx"

  network_interfaces {
    virtual_network = "VM Network"
    nic_type = "vmxnet3"
  }
}

Desktop (please complete the following information):

Additional context

2021-05-04T16:05:37.449+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: pid-54242-esxi_remote_cmds.go:61: [runRemoteSshCommand] :vmkfstools (make boot disk)
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: pid-54242-esxi_remote_cmds.go:78: [runRemoteSshCommand] cmd:/vmkfstools -c 10G -d zeroedthick ""/vmfs/volumes/SSD Home/asa-backup"/asa-backup.vmdk"/
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:  stdout:/Extra arguments at the end of the command line.
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: OPTIONS FOR FILE SYSTEMS:
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: vmkfstools -C --createfs [vmfs5|vmfs6|vfat]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -S --setfsname fsName
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -Y --unmapGranularity #[bBsSkKmMgGtT]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -O --unmapPriority <none|low|medium|high>
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -Z --spanfs span-partition
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -G --growfs grown-partition
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:    deviceName
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -P --queryfs -h --humanreadable
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -T --upgradevmfs
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:    vmfsPath
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -y --reclaimBlocks vmfsPath [--reclaimBlocksUnit #blocks]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: OPTIONS FOR VIRTUAL DISKS:
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: vmkfstools -c --createvirtualdisk #[bBsSkKmMgGtT]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -d --diskformat [zeroedthick
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |thin
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |eagerzeroedthick
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                ]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -a --adaptertype [deprecated]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -W --objecttype [file|vsan|vvol|pmem|upit]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                --policyFile <fileName>
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -w --writezeros
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -j --inflatedisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -k --eagerzero
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -K --punchzero
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -U --deletevirtualdisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -E --renamevirtualdisk srcDisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -i --clonevirtualdisk srcDisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -d --diskformat [zeroedthick
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |thin
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |eagerzeroedthick
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |rdm:<device>|rdmp:<device>
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                                |2gbsparse]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -W --object [file|vsan|vvol]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                --policyFile <fileName>
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                -N --avoidnativeclone
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -X --extendvirtualdisk #[bBsSkKmMgGtT]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                [-d --diskformat eagerzeroedthick]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -M --migratevirtualdisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -r --createrdm /vmfs/devices/disks/...
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -q --queryrdm
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -z --createrdmpassthru /vmfs/devices/disks/...
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -v --verbose #
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -g --geometry
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -x --fix [check|repair]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -e --chainConsistent
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -Q --objecttype name/value pair
ovider-esxi_v1.8.1:            --uniqueblocks childDisk
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            --dry-run [-K]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:    vmfsPath
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: OPTIONS FOR DEVICES: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -L --lock [reserve|release|lunreset|targetreset|busreset|readkeys|readresv
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:                      ] /vmfs/devices/disks/...
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            -B --breaklock /vmfs/devices/disks/...
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: OPTIONS FOR VMFS MODULE: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: 
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            --traceConfig [0|1]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            --dataTracing [0|1]
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:            --traceSize <x> (MB)
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: vmkfstools -H --help/
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: stderr:/Process exited with status 1/
2021-05-04T16:05:37.818+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: pid-54242-esxi_remote_cmds.go:61: [runRemoteSshCommand] :cleanup guest path because of failed events
2021-05-04T16:05:38.166+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: pid-54242-esxi_remote_cmds.go:78: [runRemoteSshCommand] cmd:/rm -fr "/vmfs/volumes/SSD Home/asa-backup"/
2021-05-04T16:05:38.166+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1:  stdout://
2021-05-04T16:05:38.166+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: stderr:/%!s(<nil>)/
2021-05-04T16:05:38.166+0200 [DEBUG] plugin.terraform-provider-esxi_v1.8.1: pid-54242-guest-create.go:175: [guestCREATE] Failed to vmkfstools (make boot disk):Process exited with status 1
2021/05/04 16:05:38 [DEBUG] esxi_guest.backup_appliance: apply errored, but we're indicating that via the Error pointer rather than returning it: Failed to vmkfstools (make boot disk):Process exited with status 1

Error: Failed to vmkfstools (make boot disk):Process exited with status 1

  on appliance.tf line 2, in resource "esxi_guest" "backup_appliance":
   2: resource "esxi_guest" "backup_appliance" {

2021-05-04T16:05:38.176+0200 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/josenk/esxi/1.8.1/linux_amd64/terraform-provider-esxi_v1.8.1 pid=54242
2021-05-04T16:05:38.176+0200 [DEBUG] plugin: plugin exited
josenk commented 3 years ago

Thank you for the report... Yes, it's certainly a quoting issue. It will be fixed in the next release.

josenk commented 3 years ago

Should be fixed here in 1.8.2.

https://github.com/josenk/terraform-provider-esxi/releases/tag/v1.8.2