hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
611 stars 450 forks source link

terraform 0.6.16 - Vmware Vsphere Provider - domain saved as "vsphere.local" in some network configurations #24

Closed hashibot closed 6 years ago

hashibot commented 7 years ago

This issue was originally opened by @totojack as hashicorp/terraform#6658. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

terraform 0.6.16

Affected Resource(s)

variable "vsphere_user" {}
variable "vsphere_password" {}
variable "vsphere_server" {}
variable "vsphere_cluster" {}
variable "vsphere_datacenter" {}
variable "vsphere_domain" {}
variable "vsphere_dns" {}
variable "vsphere_timezone" {}
provider "vsphere" {
user = "${var.vsphere_user}"
password = "${var.vsphere_password}"
vsphere_server = "${var.vsphere_server}"
allow_unverified_ssl = true
}
resource "vsphere_virtual_machine" "web" {
name = "terraform-web"
folder = "${vsphere_folder.testfolder.path}"
vcpu = 2
memory = 2048
datacenter = "${var.vsphere_datacenter}"
cluster = "${var.vsphere_cluster}"
domain = "my.custom.domain.com"
dns_servers = ["${var.vsphere_dns}"]
#resource_pool = ""
time_zone = "${var.vsphere_timezone}"

network_interface {
label = "virtualwire_Template"
ipv4_address = "172.16.1.19"
ipv4_prefix_length = "28"
ipv4_gateway = "172.16.1.17"
}

disk {
template = "TEMPLATE/Centos7_tmpl_20160422_01"
datastore = "VPLEX-SAS"
}
disk {
size = "20"
datastore = "VPLEX-SAS"
}
disk {
size = "10"
datastore = "VPLEX-SAS"
}
}

Debug Output

https://gist.github.com/totojack/4db892bf6d9b03b3b982401fedd8c2f6

Expected Behavior

domain value saved in files:

domain value saved as default value 'vsphere.local' in files:

add gateway to configuration terraform apply

Important Factoids

I'm testing with a Centos 7 VM on vsphere 6.

MarkDeckert commented 7 years ago

This is happening on Windows VMs as well. Just tested again in Terraform 0.9.11.

In the vm resource: domain = "${var.domain}"

Where ${var.domain} is the same variable used to join the machine to the domain elsewhere in the config - so the var itself is correct. End result as far as dns goes though is:

capture

This can be overridden and set explicitly with the dns_suffix "optional" value.

vancluever commented 6 years ago

Hey all,

This should now be functional as we have merged #185, which adds the domain to the customization spec properly. Closing this now, but if anyone is still having issues please open a new issue!

PS: To be specific on the relation of dns_suffixes and domain: the values specified in dns_suffixes actually override what is in domain, so if you want the domain name specified in domain to be a search domain as well, it needs to specifically be in dns_suffixes. This may change in futrue versions of the provider so that dns_suffixes is more like extra_dns_search_domains or something like that, to avoid duplication of values.

Thanks!