terra-farm / terraform-provider-virtualbox

VirtualBox provider for Terraform
https://terra-farm.github.io/provider-virtualbox/
MIT License
324 stars 136 forks source link

Unable to set UIID missing command #60

Closed tmwalaszek closed 5 years ago

tmwalaszek commented 5 years ago

Hi, I'm trying to create VirtualBox VM using terraform-provider-virtualbox plugin but I'm facing the following issue.

virtualbox_vm.node[1]: Creating...
virtualbox_vm.node[0]: Creating...

Error: [ERROR] Unable to set UIID: fork/exec VBoxManageinternalcommands sethduuid /Users/tmw/.terraform/virtualbox/gold/packer_vbox_virtualbox/packer-vbox-1563454030-disk001.vmdk: no such file or directory

  on main.tf line 1, in resource "virtualbox_vm" "node":
   1: resource "virtualbox_vm" "node" {

Error: [ERROR] Unable to set UIID: fork/exec VBoxManageinternalcommands sethduuid /Users/tmw/.terraform/virtualbox/gold/packer_vbox_virtualbox/packer-vbox-1563454030-disk001.vmdk: no such file or directory

  on main.tf line 1, in resource "virtualbox_vm" "node":
   1: resource "virtualbox_vm" "node" {

It looks like there is no space between VBoxManage internalcommands. It tries to find VBoxManageinternalcommands which does not exist.

Here is my environment

tmw@MBP-Tomasz:~/Infra/nomad_consul/terraform$ uname -a
Darwin MBP-Tomasz 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
tmw@MBP-Tomasz:~/Infra/nomad_consul/terraform$ terraform version
Terraform v0.12.4
+ provider.virtualbox (unversioned)
tmw@MBP-Tomasz:~/Infra/nomad_consul/terraform$ cat main.tf 
resource "virtualbox_vm" "node" {
  count = 2
  name  = format("node-%02d", count.index + 1)

  image  = "/Users/tmw/Infra/nomad_consul/terraform/../packer/packer_vbox_virtualbox.box"
  cpus   = 2
  memory = "512 mib"

  network_adapter {
    type           = "bridged"
    host_interface = "enp0s3"
  }
}

I build VirtualBox plugin myself using bf3e588a715c6fd965f6ccafadb05838d41f2caa revision. Is this a bug or I am doing something wrong?

VoyTechnology commented 5 years ago

The only thing that looks off is the image, the .. in terraform/../packer. Can you just try simplifying the path? It should work, but it might just confirm that you are resolving the correct path.

I guess we can add a path.Clean to tidy up, and os.LStat/os.Stat the file before sending it to Vbox so its a bit clearer.

Please ensure the path is correct, if it looks good I will investigate further.

tmwalaszek commented 5 years ago

Thanks for fast response :). The path is fixed now but I got the same error.

resource "virtualbox_vm" "node" {
  count = 2
  name  = format("node-%02d", count.index + 1)

  image  = "/Users/tmw/Infra/nomad_consul/packer/packer_vbox_virtualbox.box"
  cpus   = 2
  memory = "512 mib"

  network_adapter {
    type           = "bridged"
    host_interface = "enp0s3"
  }
}

Looks like a typo in the command name. It tries to execute

VBoxManageinternalcommands sethduuid

But it should

VBoxManage internalcommands sethduuid

VoyTechnology commented 5 years ago

It looks like this line might be the issue: https://github.com/terra-farm/terraform-provider-virtualbox/blob/bf3e588a715c6fd965f6ccafadb05838d41f2caa/virtualbox/resource_vm.go#L243

VoyTechnology commented 5 years ago

I have created #61, which hopefully will resolve the issue. After it is merged, please let me know if the issue has been resolved.

tmwalaszek commented 5 years ago

It works! :) Thank you very much!

VoyTechnology commented 5 years ago

Welcome! I'll close the issue now.

BlackS52 commented 2 years ago

For me this solution (https://github.com/terra-farm/terraform-provider-virtualbox/issues/101) could fix the problem.