Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use spaces in hostname with vsphere provider since #8075 #8917

Closed
Anthonie-Smit opened this issue Sep 19, 2016 · 7 comments
Closed

Cannot use spaces in hostname with vsphere provider since #8075 #8917

Anthonie-Smit opened this issue Sep 19, 2016 · 7 comments

Comments

@Anthonie-Smit
Copy link

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.

Terraform Version

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.

Affected Resource(s)

Please list the resources as a list, for example:

  • vsphere provider

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Issue description

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.

Expected Behavior

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)" )

Actual Behavior

What actually happened?
The virtual machine was not created, instead Terraform spit out the message "[ERROR] Failed trying to parse disk path:"

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
    N/A

Important Factoids

Are 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.

@jen20
Copy link
Contributor

jen20 commented Sep 20, 2016

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)?

@Anthonie-Smit
Copy link
Author

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"

linked_clone = "true"

resource_pool = "Cluster/Resources/Acc_nobackup"

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"
]
}
}

@timwsuqld
Copy link

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.

@justyns
Copy link

justyns commented Jan 9, 2017

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?

@orf
Copy link

orf commented Sep 6, 2017

FYI we are running into this error when using a datastore with a space in the name (Datastore 1). It might be related.

@sidhurana
Copy link

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.

@ghost
Copy link

ghost commented Apr 7, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants