terraform-provider-vsphere
terraform-provider-vsphere copied to clipboard
`400 Bad Request` cloning `vsphere_virtual_machine` on vSphere 8
Community Guidelines
- [X] 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
1.3.7
Terraform Provider
v2.2.0
VMware vSphere
v8.0.0
Description
We are running a evaluation of VMWare with 3 ESXi (8.0.0) nodes and vsphere 8.0.0 so a basic install with vSAN datastore
a really simple VM clone results in
Error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":
{"error_type":"INVALID_ARGUMENT","messages":[{"args":
["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of
structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},
{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure
'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
i've tried multiple vm templates, adding tags .. Because it looks like it's somehow related to the tags part. the VM will be created and isrunning running but it's marked as tainted in Terraform
Affected Resources or Data Sources
resource/vsphere_virtual_machine
Terraform Configuration
provider "vsphere" {
user = "<<snip>>"
password = "<<snip>>"
vsphere_server = "<<snip>>"
allow_unverified_ssl = true
}
data "vsphere_datacenter" "datacenter" {
# yes, that is a typo
name = "Test Datacencter"
}
data "vsphere_datastore" "datastore" {
name = "vsanDatastore"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_compute_cluster" "cluster" {
name = "Testcluster with vSAN"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_network" "network" {
name = "VM Network"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_virtual_machine" "template" {
name = "test-vm-template"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
resource "vsphere_virtual_machine" "node" {
name = "foo"
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
datastore_id = data.vsphere_datastore.datastore.id
guest_id = data.vsphere_virtual_machine.template.guest_id
scsi_type = data.vsphere_virtual_machine.template.scsi_type
network_interface {
network_id = data.vsphere_network.network.id
adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
}
disk {
label = "disk0"
size = data.vsphere_virtual_machine.template.disks.0.size
thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
}
clone {
template_uuid = "${data.vsphere_virtual_machine.template.id}"
}
}
Debug Output
https://gist.github.com/thehawkes/0696aedc098970169004bc2121f8ad91
Panic Output
No response
Expected Behavior
a working VM and a successful Terraform run
Actual Behavior
Steps to Reproduce
try to create a VM with terraform apply
on vSphere 8
Environment Details
No response
Screenshots
No response
References
No response
Hello, thehawkes! 🖐
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.
Adding more of the error seen in the output - which includes reading the tags:
2023-01-18T18:56:10.271+0100 [INFO] provider.terraform-provider-vsphere_v2.2.0_x5: 2023/01/18 18:56:10 [DEBUG] Reading tags for object "vm-1080": timestamp=2023-01-18T18:56:10.266+0100
2023-01-18T18:56:10.547+0100 [INFO] provider.terraform-provider-vsphere_v2.2.0_x5: 2023/01/18 18:56:10 [DEBUG] Tags for object "vm-1080":: timestamp=2023-01-18T18:56:10.547+0100
2023-01-18T18:56:10.548+0100 [ERROR] vertex "vsphere_virtual_machine.node" error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
2023-01-18T18:56:10.548+0100 [ERROR] vertex "vsphere_virtual_machine.node (expand)" error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
╷
│ Error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
│
│ with vsphere_virtual_machine.node,
│ on testing.tf line 32, in resource "vsphere_virtual_machine" "node":
│ 32: resource "vsphere_virtual_machine" "node" {
│
╵
2023-01-18T18:56:10.551+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-01-18T18:56:10.553+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.2.0/darwin_arm64/terraform-provider-vsphere_v2.2.0_x5 pid=4526
2023-01-18T18:56:10.553+0100 [DEBUG] provider: plugin exited
I'm not observing this error on vSphere 8.0 (yet) with VMFS:
✦ ➜ terraform init
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/vsphere versions matching ">= 2.2.0"...
- Installing hashicorp/vsphere v2.2.0...
- Installed hashicorp/vsphere v2.2.0 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
✦ ➜ terraform plan
data.vsphere_datacenter.datacenter: Reading...
data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3]
data.vsphere_datastore.datastore: Reading...
data.vsphere_compute_cluster.cluster: Reading...
data.vsphere_network.network: Reading...
data.vsphere_virtual_machine.template: Reading...
data.vsphere_network.network: Read complete after 0s [id=network-1001]
data.vsphere_datastore.datastore: Read complete after 0s [id=datastore-11]
data.vsphere_compute_cluster.cluster: Read complete after 0s [id=domain-c6045]
data.vsphere_resource_pool.pool: Reading...
data.vsphere_virtual_machine.template: Read complete after 0s [id=4202fdca-4c30-e1aa-97d4-a927e5a73db0]
data.vsphere_resource_pool.pool: Read complete after 0s [id=resgroup-6046]
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
+ create
Terraform will perform the following actions:
# vsphere_virtual_machine.vm will be created
+ resource "vsphere_virtual_machine" "vm" {
+ annotation = (known after apply)
+ boot_retry_delay = 10000
+ change_version = (known after apply)
+ cpu_limit = -1
+ cpu_share_count = (known after apply)
+ cpu_share_level = "normal"
+ datastore_id = "datastore-11"
+ default_ip_address = (known after apply)
+ efi_secure_boot_enabled = true
+ ept_rvi_mode = "automatic"
+ extra_config = {
+ "guestinfo.metadata" = "LS0tCmluc3RhbmNlLWlkOiB1YnVudHUtY2xvdWQtaW5pdApsb2NhbC1ob3N0bmFtZTogdWJ1bnR1LWNsb3VkLWluaXQKbmV0d29yazoKICB2ZXJzaW9uOiAyCiAgZXRoZXJuZXRzOgogICAgZW5zMTkyOgogICAgICBkaGNwNDogZmFsc2UKICAgICAgYWRkcmVzc2VzOgogICAgICAgIC0gMTcyLjE2LjExLjE5Mi8yNAogICAgICBnYXRld2F5NDogMTcyLjE2LjExLjEKICAgICAgbmFtZXNlcnZlcnM6CiAgICAgICAgYWRkcmVzc2VzOgogICAgICAgICAgLSAxNzIuMTYuMTEuMTEKICAgICAgICAgIC0gMTcyLjE2LjExLjEyCg=="
+ "guestinfo.metadata.encoding" = "base64"
+ "guestinfo.userdata" = "LS0tCiNjbG91ZC1jb25maWcKCnVzZXJzOgogIC0gZGVmYXVsdAogIC0gbmFtZTogdGVycmFmb3JtCiAgICBwcmltYXJ5X2dyb3VwOiB0ZXJyYWZvcm0KICAgIHN1ZG86IEFMTD0oQUxMKSBOT1BBU1NXRDpBTEwKICAgIGdyb3Vwczogc3Vkbywgd2hlZWwKICAgIHNzaF9pbXBvcnRfaWQ6IE5vbmUKICAgIGxvY2tfcGFzc3dkOiB0cnVlCiAgICBzc2hfYXV0aG9yaXplZF9rZXlzOgogICAgICAtIDxwdWJsaWNfa2V5Pgo="
+ "guestinfo.userdata.encoding" = "base64"
}
+ firmware = "efi"
+ folder = "workloads"
+ force_power_off = true
+ guest_id = "ubuntu64Guest"
+ guest_ip_addresses = (known after apply)
+ hardware_version = (known after apply)
+ host_system_id = (known after apply)
+ hv_mode = "hvAuto"
+ id = (known after apply)
+ ide_controller_count = 2
+ imported = (known after apply)
+ latency_sensitivity = "normal"
+ memory = 4096
+ memory_limit = -1
+ memory_share_count = (known after apply)
+ memory_share_level = "normal"
+ migrate_wait_timeout = 30
+ moid = (known after apply)
+ name = "ubuntu-cloud-init"
+ num_cores_per_socket = 1
+ num_cpus = 2
+ power_state = (known after apply)
+ poweron_timeout = 300
+ reboot_required = (known after apply)
+ resource_pool_id = "resgroup-6046"
+ run_tools_scripts_after_power_on = true
+ run_tools_scripts_after_resume = true
+ run_tools_scripts_before_guest_shutdown = true
+ run_tools_scripts_before_guest_standby = true
+ sata_controller_count = 0
+ scsi_bus_sharing = "noSharing"
+ scsi_controller_count = 1
+ scsi_type = "pvscsi"
+ shutdown_wait_timeout = 3
+ storage_policy_id = (known after apply)
+ swap_placement_policy = "inherit"
+ tools_upgrade_policy = "manual"
+ uuid = (known after apply)
+ vapp_transport = (known after apply)
+ vmware_tools_status = (known after apply)
+ vmx_path = (known after apply)
+ wait_for_guest_ip_timeout = 0
+ wait_for_guest_net_routable = true
+ wait_for_guest_net_timeout = 5
+ clone {
+ template_uuid = "4202fdca-4c30-e1aa-97d4-a927e5a73db0"
+ timeout = 30
}
+ disk {
+ attach = false
+ controller_type = "scsi"
+ datastore_id = "<computed>"
+ device_address = (known after apply)
+ disk_mode = "persistent"
+ disk_sharing = "sharingNone"
+ eagerly_scrub = false
+ io_limit = -1
+ io_reservation = 0
+ io_share_count = 0
+ io_share_level = "normal"
+ keep_on_remove = false
+ key = 0
+ label = "disk0"
+ path = (known after apply)
+ size = 40
+ storage_policy_id = (known after apply)
+ thin_provisioned = false
+ unit_number = 0
+ uuid = (known after apply)
+ write_through = false
}
+ network_interface {
+ adapter_type = "vmxnet3"
+ bandwidth_limit = -1
+ bandwidth_reservation = 0
+ bandwidth_share_count = (known after apply)
+ bandwidth_share_level = "normal"
+ device_address = (known after apply)
+ key = (known after apply)
+ mac_address = (known after apply)
+ network_id = "network-1001"
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these
actions if you run "terraform apply" now.
✦ ➜ terraform apply --auto-approve
data.vsphere_datacenter.datacenter: Reading...
data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3]
data.vsphere_datastore.datastore: Reading...
data.vsphere_compute_cluster.cluster: Reading...
data.vsphere_network.network: Reading...
data.vsphere_virtual_machine.template: Reading...
data.vsphere_network.network: Read complete after 0s [id=network-1001]
data.vsphere_datastore.datastore: Read complete after 0s [id=datastore-11]
data.vsphere_compute_cluster.cluster: Read complete after 0s [id=domain-c6045]
data.vsphere_resource_pool.pool: Reading...
data.vsphere_resource_pool.pool: Read complete after 0s [id=resgroup-6046]
data.vsphere_virtual_machine.template: Read complete after 0s [id=4202fdca-4c30-e1aa-97d4-a927e5a73db0]
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
+ create
Terraform will perform the following actions:
# vsphere_virtual_machine.vm will be created
+ resource "vsphere_virtual_machine" "vm" {
+ annotation = (known after apply)
+ boot_retry_delay = 10000
+ change_version = (known after apply)
+ cpu_limit = -1
+ cpu_share_count = (known after apply)
+ cpu_share_level = "normal"
+ datastore_id = "datastore-11"
+ default_ip_address = (known after apply)
+ efi_secure_boot_enabled = true
+ ept_rvi_mode = "automatic"
+ extra_config = {
+ "guestinfo.metadata" = "LS0tCmluc3RhbmNlLWlkOiB1YnVudHUtY2xvdWQtaW5pdApsb2NhbC1ob3N0bmFtZTogdWJ1bnR1LWNsb3VkLWluaXQKbmV0d29yazoKICB2ZXJzaW9uOiAyCiAgZXRoZXJuZXRzOgogICAgZW5zMTkyOgogICAgICBkaGNwNDogZmFsc2UKICAgICAgYWRkcmVzc2VzOgogICAgICAgIC0gMTcyLjE2LjExLjE5Mi8yNAogICAgICBnYXRld2F5NDogMTcyLjE2LjExLjEKICAgICAgbmFtZXNlcnZlcnM6CiAgICAgICAgYWRkcmVzc2VzOgogICAgICAgICAgLSAxNzIuMTYuMTEuMTEKICAgICAgICAgIC0gMTcyLjE2LjExLjEyCg=="
+ "guestinfo.metadata.encoding" = "base64"
+ "guestinfo.userdata" = "LS0tCiNjbG91ZC1jb25maWcKCnVzZXJzOgogIC0gZGVmYXVsdAogIC0gbmFtZTogdGVycmFmb3JtCiAgICBwcmltYXJ5X2dyb3VwOiB0ZXJyYWZvcm0KICAgIHN1ZG86IEFMTD0oQUxMKSBOT1BBU1NXRDpBTEwKICAgIGdyb3Vwczogc3Vkbywgd2hlZWwKICAgIHNzaF9pbXBvcnRfaWQ6IE5vbmUKICAgIGxvY2tfcGFzc3dkOiB0cnVlCiAgICBzc2hfYXV0aG9yaXplZF9rZXlzOgogICAgICAtIDxwdWJsaWNfa2V5Pgo="
+ "guestinfo.userdata.encoding" = "base64"
}
+ firmware = "efi"
+ folder = "workloads"
+ force_power_off = true
+ guest_id = "ubuntu64Guest"
+ guest_ip_addresses = (known after apply)
+ hardware_version = (known after apply)
+ host_system_id = (known after apply)
+ hv_mode = "hvAuto"
+ id = (known after apply)
+ ide_controller_count = 2
+ imported = (known after apply)
+ latency_sensitivity = "normal"
+ memory = 4096
+ memory_limit = -1
+ memory_share_count = (known after apply)
+ memory_share_level = "normal"
+ migrate_wait_timeout = 30
+ moid = (known after apply)
+ name = "ubuntu-cloud-init"
+ num_cores_per_socket = 1
+ num_cpus = 2
+ power_state = (known after apply)
+ poweron_timeout = 300
+ reboot_required = (known after apply)
+ resource_pool_id = "resgroup-6046"
+ run_tools_scripts_after_power_on = true
+ run_tools_scripts_after_resume = true
+ run_tools_scripts_before_guest_shutdown = true
+ run_tools_scripts_before_guest_standby = true
+ sata_controller_count = 0
+ scsi_bus_sharing = "noSharing"
+ scsi_controller_count = 1
+ scsi_type = "pvscsi"
+ shutdown_wait_timeout = 3
+ storage_policy_id = (known after apply)
+ swap_placement_policy = "inherit"
+ tools_upgrade_policy = "manual"
+ uuid = (known after apply)
+ vapp_transport = (known after apply)
+ vmware_tools_status = (known after apply)
+ vmx_path = (known after apply)
+ wait_for_guest_ip_timeout = 0
+ wait_for_guest_net_routable = true
+ wait_for_guest_net_timeout = 5
+ clone {
+ template_uuid = "4202fdca-4c30-e1aa-97d4-a927e5a73db0"
+ timeout = 30
}
+ disk {
+ attach = false
+ controller_type = "scsi"
+ datastore_id = "<computed>"
+ device_address = (known after apply)
+ disk_mode = "persistent"
+ disk_sharing = "sharingNone"
+ eagerly_scrub = false
+ io_limit = -1
+ io_reservation = 0
+ io_share_count = 0
+ io_share_level = "normal"
+ keep_on_remove = false
+ key = 0
+ label = "disk0"
+ path = (known after apply)
+ size = 40
+ storage_policy_id = (known after apply)
+ thin_provisioned = false
+ unit_number = 0
+ uuid = (known after apply)
+ write_through = false
}
+ network_interface {
+ adapter_type = "vmxnet3"
+ bandwidth_limit = -1
+ bandwidth_reservation = 0
+ bandwidth_share_count = (known after apply)
+ bandwidth_share_level = "normal"
+ device_address = (known after apply)
+ key = (known after apply)
+ mac_address = (known after apply)
+ network_id = "network-1001"
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
vsphere_virtual_machine.vm: Creating...
vsphere_virtual_machine.vm: Still creating... [10s elapsed]
vsphere_virtual_machine.vm: Still creating... [20s elapsed]
vsphere_virtual_machine.vm: Still creating... [30s elapsed]
vsphere_virtual_machine.vm: Still creating... [40s elapsed]
vsphere_virtual_machine.vm: Still creating... [50s elapsed]
vsphere_virtual_machine.vm: Still creating... [1m0s elapsed]
vsphere_virtual_machine.vm: Creation complete after 1m1s [id=420270a3-9822-a854-24c0-adce54af9166]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Under what user context are you running Terraform? e.g. [email protected]
or a user assigned a role with limited privileges.
Thanks for the quick response.
Terraform is using the default administrator@<<vspheredomain>>
user, no extra users or roles are configured.
The setup was installed from scratch ~2 weeks ago as a temporary solution to test and develop a migration path from our current ansible managed infrastructure running on oVirt to Terraform/VMWare until the official testsetup provided by a third party company is up in 1-2 months.
We are no VMware experts by any means, so it's just a basic installation with 3 nodes, vCenter, vSAN etc. running with the 60 days Evaluation License following the official VMWare docs. So local config/setup issues are possible, but not detectable atm.
The VMs created during these Terraform runs are working just fine, incl. subfolders, multiple disks and customize
linux options.
But because of the failed apply
run, the state file seems to be broken and even destroy
runs won't work.