You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a bulk provisioning setup using the Terraform VCD provider, where multiple VMs are being provisioned simultaneously. However, I’ve encountered an issue: only the first VM that is provisioned via Terraform is able to retrieve the default system metadata and also get configured, such as vm.origin.name, vm.origin.type, and vm.origin.id. The subsequent VMs do not have these default system metadata set up on the vm metadata section, even though custom system metadata can be applied correctly to all VMs.
Is this behavior a bug in the VCD provider, or is there a specific configuration or workaround I can use to ensure that all VMs (not just the first one) obtain the default system metadata?
Any insights or suggestions to resolve this issue would be greatly appreciated.
Thank you!
terraform version:
terraform -v
Terraform v1.9.8
on windows_amd64
resource: vcd_vapp_vm
Here is my code
# provider.tfvcd={
source ="vmware/vcd"
version ="3.14.0"
}
}
}
provider"vcd" {
user=var.vcd_userpassword=var.vcd_passauth_type="integrated"url=var.vcd_urlorg=var.vcd_orgvdc=var.vcd_vdcmax_retry_timeout=var.vcd_max_retry_timeoutallow_unverified_ssl=var.vcd_allow_unverified_ssl
}
# main.tf# System administrator rights are required to connect external networkdata"vcd_catalog""my-catalog" {
org=var.vcd_orgname=var.catalog_name
}
data"vcd_catalog_vapp_template""rhel9" {
org=var.vcd_orgcatalog_id=data.vcd_catalog.my-catalog.idname=var.image_name
}
resource"vcd_vapp""new_vapp" {
count=var.create_vapp?1:0# Create only if the variable is truename=var.vapp_namemetadata_entry {
key="owner"value="myself"type="MetadataStringValue"user_access="READWRITE"is_system=false
}
}
resource"vcd_vapp_org_network""direct-network" {
count=var.create_vapp?1:0vapp_name=vcd_vapp.new_vapp[count.index].nameorg_network_name=var.org_network_name
}
resource"vcd_vapp_vm""new-vm" {
for_each=var.vm_configurationsvapp_name=var.vapp_namename=each.value.hostnamecomputer_name=each.value.hostnamevapp_template_id=data.vcd_catalog_vapp_template.rhel9.idmemory=each.value.memorycpus=each.value.cpuscpu_cores=each.value.cpu_coresmemory_hot_add_enabled=truecpu_hot_add_enabled=truedescription="Build via Terraform testing depends_on = [vcd_vapp.new_vapp] #depends_on = [vcd_vapp_vm.new-vm[each.key]] metadata_entry { key = var.metadata_entry.key value = var.metadata_entry.value is_system = var.metadata_entry.is_system user_access = var.metadata_entry.user_access type = var.metadata_entry.type } network { type = var.network.type adapter_type = var.network.adapter_type name = var.network.name ip_allocation_mode = var.network.ip_allocation_mode is_primary = var.network.is_primary ip = each.value.ip connected = var.network.connected } customization { change_sid = true allow_local_admin_password = true auto_generate_password = false admin_password = var.customization_local_admin_password } dynamic "disk" { for_each = var.create_independent_disk ? [vcd_independent_disk.myNewIndependentDisk[each.key].name] : [] content { name = disk.value bus_number = 0 unit_number = 2 } }}# resource "vcd_independent_disk""myNewIndependentDisk" {# count = var.create_independent_disk ? 1 : 0# name = var.additionaldisk_configuration.name# size_in_mb = var.additionaldisk_configuration.size_in_mb# bus_type = "SCSI"# bus_sub_type = "VirtualSCSI"# }resource "vcd_independent_disk""myNewIndependentDisk" { for_each = var.create_independent_disk ? var.vm_configurations : {} name = "${each.key}-disk" # Disk name will be based on VM hostname (e.g., VM1-disk) size_in_mb = var.additionaldisk_configuration.size_in_mb bus_type = "SCSI" bus_sub_type = "VirtualSCSI"}# terraform.tfvars# EduCloud connection credentialvcd_user = "myself"vcd_pass = "myself_pass!"vcd_org = "myself-org"#vapp info# if you set create_vapp to force, it will not create # the vapp_name and org_network_name # instaed, it will use the value of vapp_name vairable# and assign it to be the vappcreate_vapp = falsevapp_name = "myself-vapp-test"org_network_name = "myself-network-p02"# VM basic information# A List of VM with arguments vm_configurations = {"myself-vm7" = { hostname = "myself-vm7" ip = "10.99.39.7" memory = 4096 cpus = 4 cpu_cores = 1 },"myself-vm8" = { hostname = "myself-vm8" ip = "10.99.39.8" memory = 4096 cpus = 4 cpu_cores = 1 }}# Metadata configmetadata_entry = { key = "group_state" value = "Group 1" is_system = false user_access = "READWRITE" type = "MetadataStringValue"}# Network config network = { type = "org" adapter_type = "VMXNET3" name = "myself-network-p02" ip_allocation_mode = "MANUAL" is_primary = true connected = true}# Local admin passwordcustomization_local_admin_password = "test_password"# Determine if you need an additional disk# if create_independent_disk is set to true# Please uncomment the additionaldisk_configuration variablecreate_independent_disk = falseadditionaldisk_configuration = { name = "disk5" size_in_mb = 20480 # Set your desired disk size here}
The text was updated successfully, but these errors were encountered:
I also noticed that for a creating a VM in a new vapp, the default system metadata is generated on the VM. But for the existing vapp, it doesn't generate the default system metadata on VMs (except the first one).
The Issue:
New vApp:
Default system metadata (vm.origin.name, vm.origin.type, vm.origin.id) is generated correctly for all VMs.
Existing vApp:
Only the first VM receives the default system metadata, while subsequent VMs do not, although custom metadata is still applied successfully.
Hi Team,
I'm working on a bulk provisioning setup using the Terraform VCD provider, where multiple VMs are being provisioned simultaneously. However, I’ve encountered an issue: only the first VM that is provisioned via Terraform is able to retrieve the default system metadata and also get configured, such as vm.origin.name, vm.origin.type, and vm.origin.id. The subsequent VMs do not have these default system metadata set up on the vm metadata section, even though custom system metadata can be applied correctly to all VMs.
Is this behavior a bug in the VCD provider, or is there a specific configuration or workaround I can use to ensure that all VMs (not just the first one) obtain the default system metadata?
Any insights or suggestions to resolve this issue would be greatly appreciated.
Thank you!
terraform version:
terraform -v
Terraform v1.9.8
on windows_amd64
resource: vcd_vapp_vm
Here is my code
The text was updated successfully, but these errors were encountered: