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

Allow datastore_cluster for content library clones with vm_templates #2268

Open
4 tasks done
Zheer09 opened this issue Sep 29, 2024 · 1 comment
Open
4 tasks done
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@Zheer09
Copy link

Zheer09 commented Sep 29, 2024

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

OpenTofu v1.8.2

Terraform Provider

v2.9.2

VMware vSphere

ESXI 7.0 U2

Description

Referencing from this https://knowledge.broadcom.com/external/article/312205/vm-template-cannot-be-deployed-to-datast.html and PR that seemed to fix this issue

I see this was tested with ovf template i am using VM templates

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

resource "vsphere_virtual_machine"

resource "vsphere_virtual_machine" "vm" {
  name                  = length(var.ip-addresses) > 1 ? "${var.name}-${count.index + 1}" : var.name
  resource_pool_id      = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_cluster_id  = data.vsphere_datastore_cluster.datastore_cluster.id
  host_system_id        = data.vsphere_host.host.id
  sata_controller_count = 1
  scsi_controller_count = 1
  count                 = length(var.ip-addresses) > 0 ? length(var.ip-addresses) : 1


  # only if you DO NOT want to wait for an IP address
  wait_for_guest_net_routable = false

  num_cpus = var.num_cpus
  memory   = var.memory
  guest_id = "ubuntu64Guest"

  network_interface {
    network_id = data.vsphere_network.network.id
  }

  disk {
    label            = "disk0"
    size             = var.disk_size
    unit_number      = 0
    thin_provisioned = false
  }

  clone {
    template_uuid = data.vsphere_content_library_item.item.id
    
    customize {
      linux_options {
        host_name = "${count.index}" > 1 ? "${var.name}-${count.index}" : var.name
        domain    = "${count.index}" > 1 ? "${var.name}-${count.index}" : var.name
      }
      network_interface {
        ipv4_address = length(var.ip-addresses) > 0 ? element(var.ip-addresses, count.index) : var.ip-address
        ipv4_netmask = 24
      }
      ipv4_gateway = "10.10.10.1"
    }
  }
}

Data file

data "vsphere_datacenter" "dc" {
  name = var.datacenter_name
}

data "vsphere_datastore_cluster" "datastore_cluster" {
  name          = var.datastore_cluster
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_content_library" "library" {
  name = "HQ-UAT"
}

data "vsphere_content_library_item" "item" {
  name       = "ubuntu-20-v1-dev-2024-09-25"
  type       = "vm-template"
  library_id = data.vsphere_content_library.library.id
}

Debug Output

None

Panic Output

No response

Expected Behavior

Creating vm with datastore cluster

Actual Behavior

I got this error

╷
│ Error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["group-p105:2e683356-6528-4429-b53e-78ab46e2136b"],"default_message":"The provided datastore ID group-p105:2e683356-6528-4429-b53e-78ab46e2136b is invalid.","id":"com.vmware.vdcs.vmtx-main.invalid_datastore_id_format"}]}}
│ 
│   with module.virtual_machine.vsphere_virtual_machine.vm[1],
│   on modules/virtual-machine/vm_machine.tf line 2, in resource "vsphere_virtual_machine" "vm":
│    2: resource "vsphere_virtual_machine" "vm" {
╵

Steps to Reproduce

Storing vm template to content library from using packer and with this configuration which getting the datastore cluster data has been validated but while creating the vm i am getting this error.

Environment Details

No response

Screenshots

No response

References

#2061

@Zheer09 Zheer09 added bug Type: Bug needs-triage Status: Issue Needs Triage labels Sep 29, 2024
Copy link

Hello, Zheer09! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

1 participant