elsudano / terraform-provider-vmworkstation

VmWare Workstation Pro provider for Terraform
MIT License
51 stars 18 forks source link

provider bugs on windows 11 familly and workstation pro 16.2.4 build-20089737 #12

Open bgranier opened 2 years ago

bgranier commented 2 years ago

Hi,

I try to use it, there are messages about Grpc then it stops ... I provide my terraform files and the apply output.

Here my main.tf file

terraform {
  required_providers {
    vmworkstation = {
      source  = "elsudano/vmworkstation"
    }
  }
}

provider "vmworkstation" {
    user="aUser"
    password="!Abcd1234"
    url="http://127.0.0.1:8697/api"
    debug=true
}

resource "vmworkstation_vm" "test_machine" {
  sourceid     = var.vmws_reource_frontend_sourceid
  denomination = var.vmws_reource_frontend_denomination
  description  = var.vmws_reource_frontend_description
  path         = var.vmws_resource_frontend_path
  processors   = var.vmws_reource_frontend_processors
  memory       = var.vmws_reource_frontend_memory
}

Here is my var.tf file


variable "vmws_reource_frontend_sourceid" {
  type        = string
  description = "(Required) The ID of the VM that to use for clone at the new"
  default = "dummyId"
}
variable "vmws_reource_frontend_denomination" {
  type        = string
  description = "(Required) The Name of VM in WS"
  default     = "Test"
}
variable "vmws_reource_frontend_description" {
  type        = string
  description = "(Required) The Description at later maybe to explain the instance"
    default = "dummy description"
}
variable "vmws_resource_frontend_path" {
  type        = string
  description = "(Required) The Path where will be our instance in VmWare"
  default = "D:\\documents\\Virtual Machine"
}
variable "vmws_reource_frontend_processors" {
  type        = string
  description = "(Required) The number of processors of the Virtual Machine"
  default     = "1"
}
variable "vmws_reource_frontend_memory" {
  type        = string
  description = "(Required) The size of memory to the Virtual Machine"
  default     = "512"
}

Apply output

Stack trace from the terraform-provider-vmworkstation_v1.0.3.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xced714]

goroutine 86 [running]:
github.com/elsudano/terraform-provider-vmworkstation/vmworkstation.resourceVMWSVmCreate(0xdfe040, {0xeafb60, 0xc0001ed7c0})
        /home/usuario/go/src/github.com/elsudano/terraform-provider-vmworkstation/vmworkstation/resource_vmworkstation_vm.go:82 +0x414
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000714640, 0xc00009e460, 0xc0000a8140, {0xeafb60, 0xc0001ed7c0})
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x438
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00051c380, 0xc00009ba68, 0xf03e8e, 0xf)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0007247d8, {0xc000700000, 0x6781a6}, 0xc000700000)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xece3c0, 0xc0007247d8}, {0x10d3bd0, 0xc000330150}, 0xc000722000, 0x0)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00027e380, {0x10e3978, 0xc000562000}, 0xc00017e100, 0xc00028c3c0, 0x16cd800, 0x0)
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc00027e380, {0x10e3978, 0xc000562000}, 0xc00017e100, 0x0)
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x294

Error: The terraform-provider-vmworkstation_v1.0.3.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
rufflabs commented 1 year ago

Similar situation here, with VMware Workstation Pro 17.0.2 build-21581411, and Windows 11 22H2 build 22621.2070.

Error in console:

vmworkstation_vm.tf-test: Creating...
vmworkstation_vm.tf-test: Still creating... [10s elapsed]
╷
│ Error: Plugin did not respond
│
│   with vmworkstation_vm.tf-test,
│   on main.tf line 19, in resource "vmworkstation_vm" "tf-test":
│   19: resource "vmworkstation_vm" "tf-test" {
│
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-vmworkstation_v1.0.3.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x16dd7a9]

goroutine 102 [running]:
github.com/elsudano/terraform-provider-vmworkstation/vmworkstation.resourceVMWSVmCreate(0x17ee040, {0x189fb60, 0xc00068cb40})
        /home/usuario/go/src/github.com/elsudano/terraform-provider-vmworkstation/vmworkstation/resource_vmworkstation_vm.go:88 +0x4a9
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00048a460, 0xc00008b7c0, 0xc00007c680, {0x189fb60, 0xc00068cb40})
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x438
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000044680, 0xc0006a7a68, 0x18f3e8e, 0xf)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000007160, {0xc0000f4070, 0x10681a6}, 0xc0000f4070)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x18be3c0, 0xc000007160}, {0x1ac3bd0, 0xc0007028a0}, 0xc000088420, 0x0)
        /home/usuario/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00022a380, {0x1ad3978, 0xc00033c000}, 0xc00069a400, 0xc000521440, 0x20bd800, 0x0)
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc00022a380, {0x1ad3978, 0xc00033c000}, 0xc00069a400, 0x0)
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /home/usuario/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x294

Error: The terraform-provider-vmworkstation_v1.0.3.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Here is my super simple main.tf:

terraform {
    required_version = ">= 1.5.4"
    required_providers {
        vmworkstation = {
            source = "elsudano/vmworkstation"
            version = "1.0.3"
        }
    }
}

provider vmworkstation {
    user = "vmrest"
    password = "VMw@re1!"
    url = "http://127.0.0.1:8697/api"
    https = false
    debug = false
}

resource "vmworkstation_vm" "tf-test" {
    sourceid = "<id here>"
    denomination = "TF-Test"
    description = ""
    path = "C:\\Virtual Machines\\TF-Test"
    processors = "2"
    memory = "4096"
}
chrodrigues commented 1 year ago

Hellow, any resolution for that?

VictorNuzhdin commented 8 months ago

Looks like we have a zombie project.. today: 2024.02.22 project_last_commit: 2021.12.12 -- 40dec72dd9d49802d34832323e59d3ac503d6707 project_last_release: 2021.12.12 -- v1.0.3

mooock commented 8 months ago

My beginning at working with Terraform and i also struggle with this error, i guess this will never get fixed, i agree it looks like the project has been abandoned

elsudano commented 8 months ago

Hi guys,

Thank you for your comments,

Believe me when I tell you that I want to finish this project more than you, but unfortunately I only have a little free time to dedicate to this project. In any case, as you can see, all the code is available so that anyone can make a PR to solve the bug or even improve the source code that is already in the repository.

Having said that, i will do my best un order to contact with VMWare and tell them if is possible that they resolve the issue that they have in their API of the VMWare workstation

Regards

mooock commented 8 months ago

its fully accepted that you don't have time. it would just help a lot maybe just write what version of vmware workstation is supported, and maybe somehow show that the project is on hold to set the expectations. It still seems that you did a pretty good work.

elsudano commented 8 months ago

Hi guys, after review the API of the VmWare Workstation, they had solved some issues that they had in the API calls, so this weekend I published another version 1.0.4

https://registry.terraform.io/providers/elsudano/vmworkstation/latest

If you want to take a look in order to see if I had be able to solve the issue, up to you.

All the feedback will be welcome

mooock commented 8 months ago

Thanks @elsudano for looking into this so quick.

has it my first time working with Terraform it might just be me doing something wrong. but i don't see the errors at least anymore. but can't get the simple demo working. also from the readme i think the information is incorrect as it don't use the correct provider name and also don't has a supplied name

but right now i get this error

vmworkstation_vm.test_machine: Creating... ╷ │ Error: One of the parameters was invalid: parentId │ │ with vmworkstation_vm.test_machine, │ on main.tf line 18, in resource "vmworkstation_vm" "test_machine": │ 18: resource "vmworkstation_vm" "test_machine" {

I also used this in my demo

resource "vmworkstation_vm" "test_machine" {
  sourceid     = var.vmws_reource_frontend_sourceid
  denomination = var.vmws_reource_frontend_denomination
  description  = var.vmws_reource_frontend_description
  path         = var.vmws_resource_frontend_path
  processors   = var.vmws_reource_frontend_processors
  memory       = var.vmws_reource_frontend_memory
}

how should the Source id be written. is it a direct copy paste from the VMX or without spaces as i did?

variable "vmws_reource_frontend_sourceid" { type = string description = "(Required) The ID of the VM that to use for clone at the new" default = "564dc542fd869b0086b5b6a3dcf10d19" }

elsudano commented 8 months ago

Thanks @elsudano for looking into this so quick.

has it my first time working with Terraform it might just be me doing something wrong. but i don't see the errors at least anymore. but can't get the simple demo working. also from the readme i think the information is incorrect as it don't use the correct provider name and also don't has a supplied name

but right now i get this error

vmworkstation_vm.test_machine: Creating... ╷ │ Error: One of the parameters was invalid: parentId │ │ with vmworkstation_vm.test_machine, │ on main.tf line 18, in resource "vmworkstation_vm" "test_machine": │ 18: resource "vmworkstation_vm" "test_machine" {

I also used this in my demo

resource "vmworkstation_vm" "test_machine" {
  sourceid     = var.vmws_reource_frontend_sourceid
  denomination = var.vmws_reource_frontend_denomination
  description  = var.vmws_reource_frontend_description
  path         = var.vmws_resource_frontend_path
  processors   = var.vmws_reource_frontend_processors
  memory       = var.vmws_reource_frontend_memory
}

how should the Source id be written. is it a direct copy paste from the VMX or without spaces as i did?

variable "vmws_reource_frontend_sourceid" { type = string description = "(Required) The ID of the VM that to use for clone at the new" default = "564dc542fd869b0086b5b6a3dcf10d19" }

You need to create a correct value file and then you need use the browser in order to know which is the value of your parentID in your VmWare Workstation.

I think that you need read more about of terraform and how to use the value files.

Moreover you need take a took at the VMWare Workstation API call documentation

I hope that help you

mooock commented 8 months ago

Found that my ID was not the correct one. did a quick powershell script to get the IDs, and now it continued. but now i struggle with the path. Maybe this a windows thing. i tried about 20 different combinations and now matter what it creates the VM, but then returns an error

Even that i added the path Virtual Machines it stores the VM in C:\Users\USERNAME\Documents\Virtual Machines

TF Variable variable "vmws_resource_frontend_path" { type = string description = "(Required) The Path where will be our instance in VmWare" default = "C:\Virtual Machines" }

Error Error: One of the parameters was invalid: path

Powershell Script to get ID

Function Get-VMwareWorkstationID {
    param (
        $username = "Mock",
        $password = "BuggerF8!"
    )
    # Encode credentials securely (adjust encoding if needed)
    $encodedCredentials = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$username`:$password"))

    # Notice the use of backtick (`) for escaping the colon
    $headers = @{
        "Authorization" = "Basic $encodedCredentials"
    }

    $url = "http://127.0.0.1:8697/api/vms"

    # Invoke the REST API and convert the response to JSON
    Invoke-RestMethod -Uri $url -Method Get -Headers $headers
}   
elsudano commented 8 months ago

Found that my ID was not the correct one. did a quick powershell script to get the IDs, and now it continued. but now i struggle with the path. Maybe this a windows thing. i tried about 20 different combinations and now matter what it creates the VM, but then returns an error

Even that i added the path Virtual Machines it stores the VM in C:\Users\USERNAME\Documents\Virtual Machines

TF Variable variable "vmws_resource_frontend_path" { type = string description = "(Required) The Path where will be our instance in VmWare" default = "C:\Virtual Machines" }

Error Error: One of the parameters was invalid: path

Powershell Script to get ID

Function Get-VMwareWorkstationID {
    param (
        $username = "Mock",
        $password = "BuggerF8!"
    )
    # Encode credentials securely (adjust encoding if needed)
    $encodedCredentials = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$username`:$password"))

    # Notice the use of backtick (`) for escaping the colon
    $headers = @{
        "Authorization" = "Basic $encodedCredentials"
    }

    $url = "http://127.0.0.1:8697/api/vms"

    # Invoke the REST API and convert the response to JSON
    Invoke-RestMethod -Uri $url -Method Get -Headers $headers
}   

First of all thanks for try the provider

Having said that, you need scape the \ so the correct one will be:

\"C:\\Users\\USERNAME\\Documents\\Virtual Machines\"

With quotes, thas is important

And is fine if you want to use the power shell script

But I think is better for you use the browser in order to know the info in your VMWare workstation.

And again, you need read more about of values files of terraform and the API calls for the vmrest, is just a suggestion

mooock commented 8 months ago

For the powershell i justed wanted to help other out that might struggle to find the correct ID. for me it took some time to realize that i could not find it directly inside VMware Workstation. So i agree that it can be found other ways as well.

I did escape escape the correct with double \ i just think git removed one of them. The point is that the path i provide seems to get overwritten by some default or hardcoded value. my plan looks like this

  # vmworkstation_vm.test_machine2 will be created
  + resource "vmworkstation_vm" "test_machine2" {
      + denomination = "Test01"
      + description  = "dummy description"
      + id           = (known after apply)
      + memory       = 2048
      + path         = "c:\\\\Virtual Machines"
      + processors   = 2
      + sourceid     = "UU1LJHCKKSBCKGDBHCBLG073VR0671EB"
    }

but it always store the vm inside this folder, and fails. i expect it to be stored in "c:\virtual Machines" folder and not the one below. C:\Users\USERNAME\Documents\Virtual Machines

not matter what i write in the path it always just returns to this default place. and use the name from the parameters.

mooock commented 8 months ago

Found out what the problem was with the path as i looked into the source code, It because i thought the path was where it should store the new VM created, but found out its the location for the VMX file. i just added the information i got from the API as escaped the backslashes, and then it continued

Now i get an error i don't understand mworkstation_vm.test_machine2: Creating... vmworkstation_vm.test_machine2: Still creating... [10s elapsed]

╷
│ Error: json: cannot unmarshal number into Go value of type wsapiclient.VmError
│
│   with vmworkstation_vm.test_machine2,
│   on main.tf line 18, in resource "vmworkstation_vm" "test_machine2":
│   18: resource "vmworkstation_vm" "test_machine2" {
mooock commented 8 months ago

I did some research about this error, don't hold me up on this one, i am a totally novice in this. But could it be caused by that the API is returning an object for the CPU cores?

This is an example from the rest call, don't know if you have taken into account that CPU is not an INT but a sub of processors { "id": "VSIV4C5TCEO55L08JVS6J2V2P43MGO8P", "cpu": { "processors": 1 }, "memory": 2048 }

elsudano commented 8 months ago

I did some research about this error, don't hold me up on this one, i am a totally novice in this. But could it be caused by that the API is returning an object for the CPU cores?

This is an example from the rest call, don't know if you have taken into account that CPU is not an INT but a sub of processors { "id": "VSIV4C5TCEO55L08JVS6J2V2P43MGO8P", "cpu": { "processors": 1 }, "memory": 2048 }

Just to inform you, if you take a look here, you can confirm that yes

https://github.com/elsudano/vmware-workstation-api-client/blob/master/wsapiclient/wsapivm.go#L9

mooock commented 8 months ago

Thanks for clarifying. You are right. The vm gets created and can be imported into vmware workstation with the correct information, so it seems to be related to output somehow

elsudano commented 8 months ago

For the powershell i justed wanted to help other out that might struggle to find the correct ID. for me it took some time to realize that i could not find it directly inside VMware Workstation. So i agree that it can be found other ways as well.

I did escape escape the correct with double \ i just think git removed one of them. The point is that the path i provide seems to get overwritten by some default or hardcoded value. my plan looks like this

  # vmworkstation_vm.test_machine2 will be created
  + resource "vmworkstation_vm" "test_machine2" {
      + denomination = "Test01"
      + description  = "dummy description"
      + id           = (known after apply)
      + memory       = 2048
      + path         = "c:\\\\Virtual Machines"
      + processors   = 2
      + sourceid     = "UU1LJHCKKSBCKGDBHCBLG073VR0671EB"
    }

but it always store the vm inside this folder, and fails. i expect it to be stored in "c:\virtual Machines" folder and not the one below. C:\Users\USERNAME\Documents\Virtual Machines

not matter what i write in the path it always just returns to this default place. and use the name from the parameters.

Today I had some time to found the correct command about of curl, so I will put here the command that maybe could help another person:

curl -k 'https://\<IP SERVER\>:8697/api/vms' -u '\<USER\>:\<PASS\>' -X GET --header 'Accept: application/vnd.vmware.vmw.rest-v1+json'

I had updated the documentation as well with this command

VictorNuzhdin commented 8 months ago

Hi, @elsudano :) Are there any plans to implement provisioning functionality as is implemented in the Terraform cloud-providers, like provisioner "remote-exec" and provisioner "local-exec"?

For example:

## Remote execute provisioner
provisioner "remote-exec" {

  ##..ssh connection section
  connection {
    type = "ssh"
    user = "VM_SYSTEM_USER"
    host = "VM_IP_ADDRESS"
    agent = true
    timeout = "3m"
  }

  ##..remote commands execution section
  inline = [
    "echo Hello",
    "echo World",
  ]
}

# Local execute provisioner
provisioner "local-exec" {
  ##..auto execute this command locally after VM created
  command = "ansible-playbook -i VM_IP_ADDRESS -u VM_SYSTEM_USER ./ansible/auto-configure.yml"
}

Thanks)

elsudano commented 8 months ago

Hi, @elsudano :) Are there any plans to implement provisioning functionality as is implemented in the Terraform cloud-providers, like provisioner "remote-exec" and provisioner "local-exec"?

For example:

## Remote execute provisioner
provisioner "remote-exec" {

  ##..ssh connection section
  connection {
    type = "ssh"
    user = "VM_SYSTEM_USER"
    host = "VM_IP_ADDRESS"
    agent = true
    timeout = "3m"
  }

  ##..remote commands execution section
  inline = [
    "echo Hello",
    "echo World",
  ]
}

# Local execute provisioner
provisioner "local-exec" {
  ##..auto execute this command locally after VM created
  command = "ansible-playbook -i VM_IP_ADDRESS -u VM_SYSTEM_USER ./ansible/auto-configure.yml"
}

Thank)

Well, that will be a good option for the future, but think about that a few seconds.

If you want to do that, you will have to prepare you own ParentID (Virtual Machine) instance with the ssh server prepared to start automatically, in order to run when you poweron the Virtual Machine.

After that, you will be able to run something similar that you put in the example, but, you will need take in account the time that the Virtual Machine take to start and prepare the SSH server, so maybe the timeout of the Terraform will be high.

At the end, the idea would be amazing but have some difficult to achieved, having said that, coud you open a Issue with this request in order to don't forget and I will take a look if is possible to make it

Thanks in advance

VictorNuzhdin commented 8 months ago

..If you want to do that, you will have to prepare you own ParentID (Virtual Machine) instance with the ssh server prepared to start automatically, in order to run when you poweron the Virtual Machine..

..but, you will need take in account the time that the Virtual Machine take to start and prepare the SSH server, so maybe the timeout of the Terraform will be high..

This is exactly what happens in the clouds - you take a pre-configured OS image that already has a configured ssh server and default ssh access to user account.. or the ability to configure it through the Cloud-Init functionality. I'll try to open Issue :)

elsudano commented 8 months ago

..If you want to do that, you will have to prepare you own ParentID (Virtual Machine) instance with the ssh server prepared to start automatically, in order to run when you poweron the Virtual Machine.. ..but, you will need take in account the time that the Virtual Machine take to start and prepare the SSH server, so maybe the timeout of the Terraform will be high..

This is exactly what happens in the clouds - you take a pre-configured OS image that already has a configured ssh server and default ssh access to user account.. or the ability to configure it through the Cloud-Init functionality. I'll try to open Issue :)

Yep, totally agreed, but in the cloud they have a lot of CPUs and maybe in your laptop you haven't enough that is my supposition, but any case is a good suggestion, I will do my best in order to achieved

mooock commented 8 months ago

@elsudano

were you able to figure out what this error was, after creating the VM?

│ Error: json: cannot unmarshal number into Go value of type wsapiclient.VmError │ │ with vmworkstation_vm.test_machine2, │ on main.tf line 29, in resource "vmworkstation_vm" "test_machine2": │ 29: resource "vmworkstation_vm" "test_machine2" {

elsudano commented 8 months ago

@elsudano

were you able to figure out what this error was, after creating the VM?

│ Error: json: cannot unmarshal number into Go value of type wsapiclient.VmError │ │ with vmworkstation_vm.test_machine2, │ on main.tf line 29, in resource "vmworkstation_vm" "test_machine2": │ 29: resource "vmworkstation_vm" "test_machine2" {

Sorry I cant replicated this error maybe you have something wrong in the input values

edi1233 commented 3 months ago

@mooock how do you fixed the issue with the path . it always failes on path , it creating the vm on vmware workstation default location. its failed even when i set the default location

elsudano commented 3 months ago

Hi @edi1233 Are you tried to escape the \ like we suggested?

I mean, if you check this comment https://github.com/elsudano/terraform-provider-vmworkstation/issues/12#issuecomment-1963051667 maybe you can resolve the issue

edi1233 commented 3 months ago

yes Terraform will perform the following actions:

vmworkstation_vm.edis will be created

Plan: 1 to add, 0 to change, 0 to destroy. vmworkstation_vm.edis: Creating... vmworkstation_vm.edis: Still creating... [10s elapsed] vmworkstation_vm.edis: Still creating... [20s elapsed] ╷ │ Error: One of the parameters was invalid: path │ │ with vmworkstation_vm.edis, │ on main.tf line 2, in resource "vmworkstation_vm" "edis": │ 2: resource "vmworkstation_vm" "edis" { │ ╵ PS C:\Users\edi\terraform\wokrstation>

elsudano commented 3 months ago

Ok , as @stiky-note point me here https://github.com/elsudano/terraform-provider-vmworkstation/issues/19#issue-2394265895 you will have to add the "state = on" variable in your code to create this VM

I will try to fix that in the next version, I mean the error output, in order to point in the correct way

edi1233 commented 3 months ago

can you show me example please where to set the state = on cause terraform give me error

Error: Unsupported argument │ │ on main.tf line 5, in resource "vmworkstation_vm" "edis": │ 5: state = "on" │ │ An argument named "state" is not expected here

elsudano commented 3 months ago

I'm pretty sure that you forgot to add the variable in the variables file, so I shared both files, I hope that will be enough to deploy your VM

Main.tf

resource "vmworkstation_vm" "vm" { sourceid = var.sourceid # The VM API need this parameter denomination = var.denomination description = var.description path = var.path processors = var.processors memory = var.memory state = var.state }

variable.tf

variable "sourceid" { type = string description = "(Required) The ID of the VM that to use for clone at the new" } variable "denomination" { type = string description = "(Required) The Name of VM in WS " default = "NewInstance" } variable "description" { type = string description = "(Required) The Description at later maybe to explain the instance " } variable "path" { type = string description = "(Required) The path where the instance is deployed " default = "D:\VirtualMachines" } variable "processors" { type = string description = "(Required) The number of processors of the Virtual Machine" default = "1" } variable "memory" { type = string description = "(Required) The size of memory to the Virtual Machine" default = "512" } variable "state" { type = string description = "(Optional) The Power State desired in the Virtual Machine" default = "off" }

edi1233 commented 3 months ago

same issue Error: Unsupported argument │ │ on main.tf line 8, in resource "vmworkstation_vm" "vm": │ 8: state = var.state │ │ An argument named "state" is not expected here.

‫בתאריך שבת, 3 באוג׳ 2024 ב-13:59 מאת ‪Carlos‬‏ @.*** ‬‏>:‬

I'm pretty sure that you forgot to add the variable in the variables file, so I shared both files, I hope that will be enough to deploy your VM

Main.tf

resource "vmworkstation_vm" "vm" { sourceid = var.sourceid # The VM API need this parameter denomination = var.denomination description = var.description path = var.path processors = var.processors memory = var.memory state = var.state }

variable.tf

variable "sourceid" { type = string description = "(Required) The ID of the VM that to use for clone at the new" } variable "denomination" { type = string description = "(Required) The Name of VM in WS " default = "NewInstance" } variable "description" { type = string description = "(Required) The Description at later maybe to explain the instance " } variable "path" { type = string description = "(Required) The path where the instance is deployed " default = "D:\VirtualMachines" } variable "processors" { type = string description = "(Required) The number of processors of the Virtual Machine" default = "1" } variable "memory" { type = string description = "(Required) The size of memory to the Virtual Machine" default = "512" } variable "state" { type = string description = "(Optional) The Power State desired in the Virtual Machine" default = "off" }

— Reply to this email directly, view it on GitHub https://github.com/elsudano/terraform-provider-vmworkstation/issues/12#issuecomment-2266675802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDX7H5JEBNUVDXJ2DRYW53ZPSZ25AVCNFSM572UPHO2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRWGY3DONJYGAZA . You are receiving this because you were mentioned.Message ID: @.*** com>