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

error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0' #2205

Closed
4 tasks done
jianglianwen opened this issue May 28, 2024 · 6 comments
Assignees
Labels
bug Type: Bug

Comments

@jianglianwen
Copy link

jianglianwen commented May 28, 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

Terraform v1.8.4 on windows_386

Terraform Provider

2.8.1

VMware vSphere

v7.0.3

Description

Hello I want to create a virtual machine by cloning it, but I get an error:

Error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0'.
│ 
│   with vsphere_virtual_machine.vm,
│   on main.tf line 1, in resource "vsphere_virtual_machine" "vm":
│    1: resource "vsphere_virtual_machine" "vm" {

Affected Resources or Data Sources

  disk {
    label            = data.vsphere_virtual_machine.template.disks.0.label
    size             = data.vsphere_virtual_machine.template.disks.0.size
    thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
  }

Terraform Configuration

main.tf

resource "vsphere_virtual_machine" "vm" {
  name = var.vsphere_virtual_machine_name
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id     = data.vsphere_datastore.datastore.id
  num_cpus         = data.vsphere_virtual_machine.template.num_cpus
  memory           = data.vsphere_virtual_machine.template.memory
  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            = data.vsphere_virtual_machine.template.disks.0.label
    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
    customize {
      linux_options {
        host_name = var.host_name
        domain    = var.domain
      }
      network_interface {
        ipv4_address    = var.ipv4_address
        ipv4_netmask    = var.ipv4_netmask
        dns_server_list = var.dns
      }
      ipv4_gateway = var.ipv4_gateway
    }
  }
}

providers.tf

provider "vsphere" {
  user                 = var.vsphere_user
  password             = var.vsphere_password
  vsphere_server       = var.vsphere_server
  allow_unverified_ssl = true
}

versions.tf

terraform {
  required_providers {
    vsphere = {
      source  = "hashicorp/vsphere"
      version = "2.8.1"
    }
  }
}

data.tf

data "vsphere_datacenter" "datacenter" {
  name = var.vsphere_datacenter_name
}

data "vsphere_datastore" "datastore" {
  name          = var.vsphere_datastore_name
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_compute_cluster" "cluster" {
  name          = var.vsphere_compute_cluster_name
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_network" "network" {
  name          = var.vsphere_network_name
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_resource_pool" "pool" {
  name          = var.resource_pool_id
  datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_virtual_machine" "template" {
  name          = var.vsphere_virtual_machine_template_name
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

variables.tf

variable "vsphere_user" {
  type        = string
  description = "username"
}

variable "vsphere_password" {
  type        = string
  description = "password"
}

variable "vsphere_server" {
  type        = string
  description = "https://"
}

variable "vsphere_datacenter_name" {
  type        = string
  description = "vsphere_datacenter_name"
}

variable "vsphere_datastore_name" {
  type        = string
  description = "vsphere_datastore_name"
}

variable "vsphere_compute_cluster_name" {
  type        = string
  description = "vsphere_compute_cluster_name"
}

variable "vsphere_network_name" {
  type        = string
  description = "VM Network"
}

variable "vsphere_virtual_machine_template_name" {
  type        = string
  description = "vsphere_virtual_machine_template_name"
}

variable "vsphere_virtual_machine_name" {
  type        = string
  description = "vsphere_virtual_machine_name"
}

variable "host_name" {
  type        = string
  description = "host_name"
}

variable "domain" {
  type        = string
  description = "domain"
}

variable "ipv4_address" {
  type        = string
  description = "ipv4_address"
}

variable "ipv4_netmask" {
  type        = string
  description = "ipv4_netmask"
}

variable "ipv4_gateway" {
  type        = string
  description = "ipv4_gateway"
}

variable "dns" {
  type        = list(any)
  description = "dns"
}

variable "resource_pool_id" {
  type        = string
  description = "resource_pool_id"
}

terraform.tfvars

vsphere_user                          = "xx"
vsphere_password                      = "xx"
vsphere_server                        = "xxvcenter.com"
vsphere_datacenter_name               = "Datacenter"
vsphere_datastore_name                = "Datastore"
vsphere_compute_cluster_name          = "vsan"
vsphere_network_name                  = "network"
vsphere_virtual_machine_template_name = "centos7-tpl"
vsphere_virtual_machine_name          = "test-clone-terraform"
host_name                             = "test-clone-terraform"
domain                                = "test-clone-terraform"
ipv4_address                          = "10.80.51.234"
ipv4_netmask                          = "20"
ipv4_gateway                          = "10.80.50.1"
dns                                   = ["10.80.51.76", "10.80.51.77", "1.1.1.1"]
resource_pool_id                      = "test"`

Debug Output


Panic Output

No response

Expected Behavior

create virtal mashine

Actual Behavior

error

Steps to Reproduce

terraform plan
`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-7032"

    • default_ip_address = (known after apply)

    • ept_rvi_mode = "automatic"

    • extra_config_reboot_required = true

    • firmware = "bios"

    • force_power_off = true

    • guest_id = "centos7_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 = 8192

    • memory_limit = -1

    • memory_share_count = (known after apply)

    • memory_share_level = "normal"

    • migrate_wait_timeout = 30

    • moid = (known after apply)

    • name = "test-clone-terraform"

    • num_cores_per_socket = 1

    • num_cpus = 4

    • power_state = (known after apply)

    • poweron_timeout = 300

    • reboot_required = (known after apply)

    • resource_pool_id = "resgroup-7133"

    • 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"

    • sync_time_with_host = true

    • 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 = "42393058-8137-f6fa-f073-581093426ccc"

      • timeout = 30

      • customize {

        • ipv4_gateway = "10.80.50.1"

        • timeout = 10

        • linux_options {

          • domain = "test-clone-terraform"
          • host_name = "test-clone-terraform"
          • hw_clock_utc = true
            }
        • network_interface {

          • dns_server_list = [
            • "10.80.51.76",
            • "10.80.51.77",
            • "1.1.1.1",
              ]
          • ipv4_address = "10.80.51.234"
          • ipv4_netmask = 20
            }
            }
            }
    • disk {

      • attach = false
      • controller_type = "scsi"
      • datastore_id = ""
      • 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 = "Hard disk 1"
      • path = (known after apply)
      • size = 100
      • 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-5003"
        }
        }**terraform apply**vsphere_virtual_machine.vm: Creating...
        vsphere_virtual_machine.vm: Still creating... [10s elapsed]

        │ Error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0'.

        │ with vsphere_virtual_machine.vm,
        │ on main.tf line 1, in resource "vsphere_virtual_machine" "vm":
        │ 1: resource "vsphere_virtual_machine" "vm" {

        ╵`

Environment Details

No response

Screenshots

image

References

#1809

@jianglianwen jianglianwen added bug Type: Bug needs-triage Status: Issue Needs Triage labels May 28, 2024
Copy link

Hello, jianglianwen! 🖐

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.

@jianglianwen
Copy link
Author

image
image
image
image
image
image

@tenthirtyam tenthirtyam added this to the Backlog milestone Jun 12, 2024
@tenthirtyam tenthirtyam changed the title Error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0'. error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0' Jun 13, 2024
@spacegospod
Copy link
Collaborator

Hey @jianglianwen this is an error thrown by vCenter. There's probably a more detailed message in the task console and in the logs.

Did you try the same operation via the vCenter UI?

@tenthirtyam tenthirtyam added waiting-response Status: Waiting on a Response and removed needs-triage Status: Issue Needs Triage labels Jul 8, 2024
@github-actions github-actions bot removed the waiting-response Status: Waiting on a Response label Sep 6, 2024
@jianglianwen
Copy link
Author

我将版本升级到2.9.0就没问题了

@tenthirtyam
Copy link
Collaborator

Might have been related to the sdk update.

@tenthirtyam tenthirtyam removed this from the Backlog milestone Sep 17, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants