Skip to content
New issue

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

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

Already on GitHub? # to your account

Make creation of vsphere_virtual_machine not dependent on resource_pool_id #1249

Closed
patshuff opened this issue Oct 27, 2020 · 2 comments · Fixed by #1620
Closed

Make creation of vsphere_virtual_machine not dependent on resource_pool_id #1249

patshuff opened this issue Oct 27, 2020 · 2 comments · Fixed by #1620
Assignees
Labels
acknowledged Status: Issue or Pull Request Acknowledged area/vm Area: Virtual Machines documentation Type: Documentation enhancement Type: Enhancement
Milestone

Comments

@patshuff
Copy link

patshuff commented Oct 27, 2020

Description

For many small vSphere installations no resource pool is declared and the default Resources resource pool is used. For multiple servers this becomes a problem because the default for the resource pool is "Resources" on all servers. If this tag is used in Terraform it throws an error since there are multiple names and the names must be unique.

It would be so much simpler to allow for resource_pool_id or host_system_id to be used rather than having to synthetically name the multiple "Resources" as something else. Allowing a vsphere_virtual_machine to not require a resource_pool_id but accept a resource_pool_id or host_system_id and assume that the resource pool is Resources if none is declared. This removes the lines of code to define a virtual machine and makes virtual machine creation much simpler for smaller installations.

Potential Terraform Configuration

current

data "vsphere_host" "Host-10_0_0_92" {
   name = "10.0.0.92"
   datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_resource_pool" "Resources-10_0_0_92" {
   name = "10.0.0.92/Resources"
   datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_host" "Host-10_0_0_3" {
   name = "10.0.0.3"
   datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_resource_pool" "Resources-10_0_0_3" {
   name = "10.0.0.3/Resources"
   datacenter_id = data.vsphere_datacenter.dc.id
}
resource "vsphere_virtual_machine" "vm" {
   name = "terraform-test"
   resource_pool_id = data.vsphere_resource_pool.Resources-10_0_0_92.id
   host_system_id = data.vsphere_host.Host-10_0_0_92.id
   guest_id = "windows9_64Guest"
   network_interface {
     network_id = data.vsphere_network.VMNetwork.id
   }
   disk {
     label = "Disk0"
         size = 40
   }
   clone {
     template_uuid = data.vsphere_virtual_machine.win_10_template.id
   }
}

proposed

data "vsphere_host" "Host-prod" {
   name = "10.0.0.92"
   datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_host" "Host-dev" {
   name = "10.0.0.3"
   datacenter_id = data.vsphere_datacenter.dc.id
}

resource "vsphere_virtual_machine" "vm" {
   name = "terraform-test"
   host_system_id = data.vsphere_host.Host-prod.id
   guest_id = "windows9_64Guest"
   network_interface {
     network_id = data.vsphere_network.VMNetwork.id
   }
   disk {
     label = "Disk0"
         size = 40
   }
   clone {
     template_uuid = data.vsphere_virtual_machine.win_10_template.id
   }
}

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@patshuff patshuff added the enhancement Type: Enhancement label Oct 27, 2020
@tenthirtyam
Copy link
Collaborator

@patshuff, an alternative approach is also:

data "vsphere_compute_cluster" "cluster" {
  name          = var.vsphere_cluster
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_resource_pool" "resource_pool" {
  name          = format("%s%s", data.vsphere_compute_cluster.cluster.name, "/Resources")
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

Do you think this would be beneficial to add to the documentation?

Hope this helps,
Ryan

@tenthirtyam

@tenthirtyam tenthirtyam added the acknowledged Status: Issue or Pull Request Acknowledged label Feb 4, 2022
@tenthirtyam tenthirtyam changed the title make creation of resource vsphere_virtual_machine not dependent upon resource_pool_id Make creation of vsphere_virtual_machine not dependent on resource_pool_id Feb 5, 2022
@tenthirtyam tenthirtyam added the waiting-response Status: Waiting on a Response label Feb 13, 2022
@tenthirtyam tenthirtyam self-assigned this Feb 17, 2022
@tenthirtyam tenthirtyam added documentation Type: Documentation area/vm Area: Virtual Machines labels Feb 17, 2022
@tenthirtyam tenthirtyam added this to the v2.2.0 milestone Mar 10, 2022
@tenthirtyam tenthirtyam removed waiting-response Status: Waiting on a Response labels Mar 10, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
acknowledged Status: Issue or Pull Request Acknowledged area/vm Area: Virtual Machines documentation Type: Documentation enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants