-
Notifications
You must be signed in to change notification settings - Fork 452
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
error reconfiguring virtual machine: Invalid operation for device '0'. #1809
Comments
May we ask that you please format HCL using the GotHub markdown editor for readability? |
As a test, try changing the disk {
label = "disk0"
size = data.vsphere_virtual_machine.template.disks[0].size
eagerly_scrub = data.vsphere_virtual_machine.template.disks[0].eagerly_scrub
thin_provisioned = data.vsphere_virtual_machine.template.disks[0].thin_provisioned
} |
Hi , this goes through without error . VMs created as same disk size like in template. |
Ok, this narrows the issue down to this stanza for further review. |
When you ran the plan for the stanza change, what was the disk size returned from the datasource - your variable must be the same or greater. |
variable is greater then disk size in template, I set to 16 . disk_size = "16" ... disk {
label = local.disk_label
size = local.disk_size
thin_provisioned = local.disk_thin
} |
Can you provide the plan output to confirm? Any change if you add |
this is plan output when I use my configuration ( Part regarding for first vm, it's the same for second) : 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["terraVM1"] 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-16"
+ default_ip_address = (known after apply)
+ ept_rvi_mode = "automatic"
+ firmware = "bios"
+ force_power_off = true
+ guest_id = "rhel8_64Guest"
+ 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 = 2048
+ memory_limit = -1
+ memory_share_count = (known after apply)
+ memory_share_level = "normal"
+ migrate_wait_timeout = 30
+ moid = (known after apply)
+ name = "terraVM1"
+ 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-19007"
+ 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 = "422d42a5-8ede-0153-85f4-0da1608efb53"
+ timeout = 30
+ customize {
+ ipv4_gateway = "192.168.71.1"
+ timeout = 10
+ linux_options {
+ domain = "me.local"
+ host_name = "terraVM1"
+ hw_clock_utc = true
}
+ network_interface {
+ dns_server_list = [
+ "8.8.8.8",
+ "8.8.4.4",
]
+ ipv4_address = "192.168.1.101"
+ ipv4_netmask = 24
}
}
}
+ 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 = 16
+ storage_policy_id = (known after apply)
+ thin_provisioned = true
+ 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 = "dvportgroup-19008"
}
} This is plan output when I change disk stanza , like you wrote : 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["terraVM1"] 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-16"
+ default_ip_address = (known after apply)
+ ept_rvi_mode = "automatic"
+ firmware = "bios"
+ force_power_off = true
+ guest_id = "rhel8_64Guest"
+ 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 = 2048
+ memory_limit = -1
+ memory_share_count = (known after apply)
+ memory_share_level = "normal"
+ migrate_wait_timeout = 30
+ moid = (known after apply)
+ name = "terraVM1"
+ 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-19007"
+ 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 = "422d42a5-8ede-0153-85f4-0da1608efb53"
+ timeout = 30
+ customize {
+ ipv4_gateway = "192.168.1.1"
+ timeout = 10
+ linux_options {
+ domain = "me.local"
+ host_name = "terraVM1"
+ hw_clock_utc = true
}
+ network_interface {
+ dns_server_list = [
+ "8.8.8.8",
+ "8.8.4.4",
]
+ ipv4_address = "192.168.1.102"
+ ipv4_netmask = 24
}
}
}
+ disk {
+ attach = false
+ controller_type = "scsi"
+ datastore_id = "<computed>"
+ device_address = (known after apply)
+ disk_mode = "persistent"
+ disk_sharing = "sharingNone"
+ eagerly_scrub = true
+ 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 = 10
+ 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 = "dvportgroup-19008"
}
} |
First, this does help to confirm that the source template’s As a test, set your (Keep in mind that Boolean values do not need quotes in your locals.) locals {
…
disk_label = "disk0"
disk_size = "10"
disk_thin = true
disk_eagerly_scrub = true
} disk {
label = local.disk_label
size = local.disk_size
thin_provisioned = local.disk_thin
eagerly_scrub = local.disk_eagerly_scrub
} Let’s use this test to troubleshoot further. |
So i try , like this locals {
...
disk_label = "disk0"
disk_size = "10"
disk_thin = true
disk_eagerly_scrub = false
} disk {
label = local.disk_label
size = local.disk_size
thin_provisioned = local.disk_thin
eagerly_scrub = local.disk_eagerly_scrub
} It's create vm, but won't boot VM , on console of VM I can see "Operating system not found...." apply output Terraform will perform the following actions:
# vsphere_virtual_machine.vm["terraVM1"] 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-16"
+ default_ip_address = (known after apply)
+ ept_rvi_mode = "automatic"
+ firmware = "bios"
+ force_power_off = true
+ guest_id = "rhel8_64Guest"
+ 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 = 2048
+ memory_limit = -1
+ memory_share_count = (known after apply)
+ memory_share_level = "normal"
+ migrate_wait_timeout = 30
+ moid = (known after apply)
+ name = "terraVM1"
+ 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-19007"
+ 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 = "422d42a5-8ede-0153-85f4-0da1608efb53"
+ 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 = 10
+ storage_policy_id = (known after apply)
+ thin_provisioned = true
+ 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 = "dvportgroup-19008"
}
} I edited template and set disk to thin . Maybe I should create a new temple. |
Regarding not booting - is the virtual machine template using EFI or EFI with secure boot? If so, keep in mind that EFI firmware = "efi"
efi_secure_boot_enabled = false EFI with Secure Boot firmware = "efi"
efi_secure_boot_enabled = true You could use the Packer examples from my other project. |
yes , that solvet the problem with booting . But still can't change disk size . I try with second template Ubuntu 22(jammy-server-cloudimg-amd64) same behavior . I try to provision VM , no use of template . resource "vsphere_virtual_machine" "vm" {
name = "foo"
resource_pool_id = data.vsphere_compute_cluster.compute_cluster.resource_pool_id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = 1
memory = 1024
guest_id = "other3xLinux64Guest"
network_interface {
network_id = data.vsphere_network.net.id
}
disk {
label = "disk0"
size = 20
}
} but , no luck , |
Thanks for confirming this test. I’ll follow up when I have additional time to review. |
Hi, have the same problem, can you help or need to wait version 2.5.0? Terraform Terraform Provider VMware vSphere Datasources
Variables
Main
When i run plan command, everything all right:
But apply gives me Errors:
|
Addressed in #1996 |
This functionality has been released in v2.4.2 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Guidelines
Terraform
v1.3.6
Terraform Provider
v2.2.0
VMware vSphere
7.0.3
Description
hi ,
I want to provision two virtual machines from template, template is created from alma linux ( cloud init image). But I am getting error : Error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0'.
When I try to manualy create VM through GUI in vcenter , there is no problem .
Affected Resources or Data Sources
Terraform Configuration
main.tf
variables.tf
Debug Output
Panic Output
No response
Expected Behavior
to create two virtal mashines
Actual Behavior
error
Steps to Reproduce
terrafrom plan :
Terraform apply
Environment Details
No response
Screenshots
No response
References
No response
The text was updated successfully, but these errors were encountered: