Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.
Terraform v0.7.3.
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Since ticket #8075 there is a bug in working with Virtual Machine names that contain the space character in their name. In #8075 the datastore references have been changed, which uses a split on the space character.
Please revert to resource_vsphere_virtual_machine.go, lines 968 to 978 and review the split on a space character please.
What should have happened?
Virtual machine should have been created, with spaces in it's object name (e.g. "ams-web-01.contoso.com (Web Server)" )
What actually happened?
The virtual machine was not created, instead Terraform spit out the message "[ERROR] Failed trying to parse disk path:"
Please list the steps required to reproduce the issue, for example:
terraform applyAre there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?
N/A
For the moment we reverted back to Terraform Terraform v0.6.16. Due to this bug we cannot update Terraform without breaking stuff in our environment.
Hi @Anthonie-Smit! I'm not familiar enough with Vsphere to be able to address this immediately, but can you confirm whether you mean the _object name_ as per the body text (in which case this is likely a bug) or the _hostname_ as per the title (in which case spaces are prohibited by RFC1123)?
Hi @jen20 . I meant the object name for the virtual machine in VMware. We provide new virtual machines with a description in the object name for ease of identification. For example we use an object name like this: ams-app-01 (Application Server)
With the previous versions of Terraform this wasn't an issue. However with the changes that I highlighted the object name is being split on a space character, which fails our deployment.
Here is a terraform template that works with Terraform v0.6.16 and fails with Terraform v0.7.3:
provider "vsphere" {
user = "SECRET_USERNAME"
password = "SECRET_PASSWORD"
vsphere_server = "vcenter.contoso.com"
allow_unverified_ssl = true
}
resource "vsphere_virtual_machine" "test-vm0" {
name = "ams-app-01.contoso.com (Application Server)"
datacenter = "Datacenter"
cluster = "test-cluster"
vcpu = "2"
memory = "4096"
dns_suffixes = ["contoso.com"]
dns_servers = ["_._._._", "_._._._", "_._._._"]
domain = "contoso.com"
network_interface {
label = "SERVER VLAN"
ipv4_address = "_._._._"
ipv4_prefix_length = "24"
ipv4_gateway = "_._._._"
}
disk {
template = "Templates/LINUX_TEMPLATE"
datastore = "NFS_RAM"
type = "thin"
}
disk {
size = "20"
datastore = "NFS_RAM"
type = "thin"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "SECRET_USERNAME"
password = "SECRET_PASSWORD"
}
inline = [
"Some post-deployment commands"
]
}
}
This is also an issue if the Datastore name contains spaces.
It looks like we rely on the space between the datastore name, and the hostname/filename (https://github.com/hashicorp/terraform/blob/master/builtin/providers/vsphere/resource_vsphere_virtual_machine.go#L976) to perform the split.
I just ran into a similar issue where the datastore had a space in the name. I'm not familiar enough with vsphere to know if the format is always the same, but maybe it should be parsing the datastore out of the [] brackets instead of splitting on the first space?
FYI we are running into this error when using a datastore with a space in the name (Datastore 1). It might be related.
My network label also contain space and somehow it's failing in that case as well. Error : vm network not found. Let me know if anyone faced same issue.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.