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

Clone from content library item with windows_options #2131

Open
4 tasks done
alonkaliber opened this issue Feb 12, 2024 · 1 comment
Open
4 tasks done

Clone from content library item with windows_options #2131

alonkaliber opened this issue Feb 12, 2024 · 1 comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@alonkaliber
Copy link

alonkaliber commented Feb 12, 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

v1.6.6

Terraform Provider

v1.6.6

VMware vSphere

v2.6.1

Description

Hey when trying to clone a VM from content_library_item which is an OVA it works, but when trying to customize, i get this error suddenly

│ Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found
│ 
│   with vsphere_virtual_machine.be_win_vms[2],
│   on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│  136: resource "vsphere_virtual_machine" "be_win_vms" {
│ 
╵
╷
│ Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found
│ 
│   with vsphere_virtual_machine.be_win_vms[0],
│   on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│  136: resource "vsphere_virtual_machine" "be_win_vms" {
│ 
╵
╷
│ Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found
│ 
│   with vsphere_virtual_machine.be_win_vms[1],
│   on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│  136: resource "vsphere_virtual_machine" "be_win_vms" {
│ 

This is my code

only when i try to customize i get that error, why does that happen ?

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

data "vsphere_content_library" "content_library" {
  name = "Servers"
}

data "vsphere_content_library_item" "windows_image_item" {
  depends_on = [
    vsphere_content_library_item.windows_ova,
    time_sleep.windows_nap
  ]
  name       = "windows_image"
  type       = "ovf"
  library_id = data.vsphere_content_library.content_library.id
}

data "vsphere_content_library_item" "linux_image_item" {
  depends_on = [
    vsphere_content_library_item.linux_ova,
    time_sleep.linux_nap
  ]
  name       = "linux_image"
  type       = "ovf"
  library_id = data.vsphere_content_library.content_library.id
}

resource "vsphere_content_library_item" "windows_ova" {
  name        = "windows_image"
  description = "Windows Image"
  file_url    = var.windows_image_local_path
  library_id  = data.vsphere_content_library.content_library.id
}

resource "vsphere_content_library_item" "linux_ova" {
  name        = "linux_image"
  description = "Linux Image"
  file_url    = var.linux_image_local_path
  library_id  = data.vsphere_content_library.content_library.id
}

resource "time_sleep" "windows_nap" {
  depends_on = [
    vsphere_content_library_item.windows_ova
  ]
  create_duration = "120s"
}

resource "time_sleep" "linux_nap" {
  depends_on = [
    vsphere_content_library_item.linux_ova
  ]
  create_duration = "120s"
}


// cloneings 
resource "vsphere_virtual_machine" "cp_win_vms" {
  depends_on = [
    data.vsphere_content_library_item.windows_image_item
  ]
  count = 3
  name  = "cp_win_${count.index + 1}"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id     = data.vsphere_datastore.EMC_SecondVolume.id
  host_system_id   = data.vsphere_host.esxi_3.id
  firmware = "efi"
  num_cpus = 4
  memory   = 16384 # 16GB
  guest_id = "windows9Server64Guest"
  folder = var.vcenter_folder
  scsi_type = "lsilogic-sas"
  nested_hv_enabled = true
  network_interface {
    network_id 	 = data.vsphere_network.network.id
  }
  disk {
    label            = "disk0"
    size             = 100
    thin_provisioned = true
  }  
  clone {
    template_uuid = data.vsphere_content_library_item.windows_image_item.id
	  timeout = 30
   }
}

resource "vsphere_virtual_machine" "be_win_vms" {
  depends_on = [
    data.vsphere_content_library_item.windows_image_item
  ]
  count = 3
  name  = "be_win_${count.index + 1}"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id     = data.vsphere_datastore.EMC_SecondVolume.id
  host_system_id   = data.vsphere_host.esxi_1.id
  guest_id = "windows9Server64Guest"
  folder           = var.vcenter_folder
  firmware         = "efi"
  scsi_type        = "lsilogic-sas"
  num_cpus         = 8
  memory           = 16384 # 16GB
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout  = 0
  nested_hv_enabled = true
  network_interface {
      network_id = data.vsphere_network.network.id
  }
  disk {
    label            = "disk0"
    size             = 100
    thin_provisioned = true
  }
  clone {
    template_uuid = data.vsphere_content_library_item.windows_image_item.id
	  timeout = 30
    customize {
      windows_options {
        computer_name  = "be_win_${count.index + 1}"
        join_domain    = var.domain_name
        domain_admin_user = var.domain_admin_user
        domain_admin_password = var.domain_admin_password
      }
      network_interface {}
    }
   }
}

Debug Output

https://gist.github.com/alonkaliber/43eb78e64bc11ae39dd752d93a2f7d8a

Panic Output

No response

Expected Behavior

Expect terraformto have the ability to customize the vm's

Actual Behavior

Got these errors
Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found

│ with vsphere_virtual_machine.be_win_vms[2],
│ on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│ 136: resource "vsphere_virtual_machine" "be_win_vms" {



│ Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found

│ with vsphere_virtual_machine.be_win_vms[0],
│ on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│ 136: resource "vsphere_virtual_machine" "be_win_vms" {



│ Error: cannot locate virtual machine or template with UUID "": virtual machine with UUID "" not found

│ with vsphere_virtual_machine.be_win_vms[1],
│ on vSphere.tf line 136, in resource "vsphere_virtual_machine" "be_win_vms":
│ 136: resource "vsphere_virtual_machine" "be_win_vms" {

Steps to Reproduce

Add an OVA to content library, try to clone a VM from with it windows_options included

Environment Details

No response

Screenshots

No response

References

No response

@alonkaliber alonkaliber added bug Type: Bug needs-triage Status: Issue Needs Triage labels Feb 12, 2024
Copy link

Hello, alonkaliber! 🖐

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