terra-farm / terraform-provider-virtualbox

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

Error: [ERROR] Wait VM until ready: waiting for VM (node-01) to become ready: [ERROR] can't convert vbox network to terraform data: No match with get guestproperty output #149

Open mohang6770 opened 2 years ago

mohang6770 commented 2 years ago

Terraform Version

<MISSING>

Virtualbox Provider version

<MISSING>

Operating System

<MISSING>

Describe the Bug

<MISSING>

To Reproduce

Steps to reproduce the behavior:

  1. <MISSING>

Expected Behaviour

<MISSING>

Configuration

terraform {
  required_providers {
    virtualbox = {
      source = "terra-farm/virtualbox"
      version = "0.2.2-alpha.1"
    }
  }
}

resource "virtualbox_vm" "node" {
  count     = 1
  name      = format("node-%02d", count.index + 1)
  image     = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20210916.0.0/providers/virtualbox.box"
  cpus      = 1
  memory    = "1024 mib"
  user_data = file("${path.module}/user_data.sh")

  network_adapter {
    type           = "nat"
  }
  network_adapter {
    type           = "bridged"
    host_interface = "eno1"
  }

  network_adapter {
    type           = "hostonly"
    host_interface = "vboxnet1"
  }
}

output "IPAddr" {
  value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)
}

output "IPAddr_2" {
  value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2)
}

Log Output

Error: [ERROR] Wait VM until ready: waiting for VM (node-01) to become ready: [ERROR] can't convert vbox network to terraform data: No match with get guestproperty output
billyjsubs commented 2 years ago

snap.

VoyTechnology commented 2 years ago

Hi @mohang6770, thank you for submitting this issue. I took some liberty in applying the latest issue template to this bug report, I hope you don't mind. Can you please provide some of the missing fields? Thank you.

nikstuckenbrock commented 1 year ago

I think the issues #138 and #134 report the same problem. Maybe a maintainer could close them as duplicates. I have the same issue using the following configuration:

Terraform version

v1.2.2

Virtualbox provider version

v0.2.2-alpha.1

Operating system

Debian 11

Describe the bug

This is my terraform configuration I'm trying to apply.

terraform {
  required_providers {
    virtualbox = {
      source = "terra-farm/virtualbox"
      version = "0.2.2-alpha.1"
    }
  }
}

# There are currently no configuration options for the provider itself.

resource "virtualbox_vm" "node" {
  count     = 2
  name      = format("node-%02d", count.index + 1)
  image     = "virtualbox_windows-10.box"
  network_adapter {
    type           = "hostonly"
    host_interface = "vboxnet0"
  }
}

output "IPAddr" {
  value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)
}

output "IPAddr_2" {
  value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2)
}

When I apply the configuration file two virtual machines are created and one of them is running, the other is powered off. Then I run into the following error message:

╷
│ Error: [ERROR] Wait VM until ready: waiting for VM (node-02) to become ready: [ERROR] can't convert vbox network to terraform data: No match with get guestproperty output
│
│   with virtualbox_vm.node[1],
│   on main.tf line 12, in resource "virtualbox_vm" "node":
│   12: resource "virtualbox_vm" "node" {
│
╵
╷
│ Error: [ERROR] Clone *.vdi and *.vmdk to VM folder: exit status 1
│
│   with virtualbox_vm.node[0],
│   on main.tf line 12, in resource "virtualbox_vm" "node":
│   12: resource "virtualbox_vm" "node" {
│
╵

To Reproduce

Just use the provided terraform file with a windows box.

Expected behaviour

I would just expect the build to finish. The network used in the configuration exists.

nikstuckenbrock commented 1 year ago

I think I found the bug in the terra-form/go-virtualbox repository and have created a pull request for it. You can find further details on the bug in the PR.

mohang6770 commented 1 year ago

Thanks

On Tue, 25 Oct 2022, 07:25 Nik Stuckenbrock, @.***> wrote:

I think I found the bug in the terra-form/go-virtualbox repository and have created a pull request https://github.com/terra-farm/go-virtualbox/pull/43 for it.

— Reply to this email directly, view it on GitHub https://github.com/terra-farm/terraform-provider-virtualbox/issues/149#issuecomment-1290045036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALUP4V2AZXBCHFJCQTBAYL3WE54NNANCNFSM576YC3WA . You are receiving this because you were mentioned.Message ID: @.*** com>

VoyTechnology commented 1 year ago

Hey @nikstuckenbrock, now that your change is merged, do you want to create another PR to this repository to bump the go-virtualbox dependency version?

nikstuckenbrock commented 1 year ago

Hey @VoyTechnology, thanks for reaching out. I've provided a new PR #155 to bump the version.

VoyTechnology commented 1 year ago

Merged. Can you validate that the problem has been fixed? If so, I will tag a new release.

nikstuckenbrock commented 1 year ago

Hey @VoyTechnology , build proceeds now and resolves in another error. So reading out the guestproperty works now. You could flag a new release or wait until I have investigated the new error message if you want.

Update: It seems like it's not really an error. The time waiting for the VM to become available is set to 30 seconds which seems to be to short for my use case. I would be a nice feature though.

mohang6770 commented 1 year ago

Error: [ERROR] Setup VM properties: exit status 1 │ │ with module.kmaster-1.virtualbox_vm.node, │ on .terraform/modules/kmaster-1/main.tf line 10, in resource "virtualbox_vm" "node": │ 10: resource "virtualbox_vm" "node" {

code: terraform { required_providers { virtualbox = { source = "terra-farm/virtualbox" version = "0.2.2-alpha.1" } } }

resource "virtualbox_vm" "node" { name = var.vm_name image = var.image cpus = var.cpu memory = var.memory

network_adapter { type = "Nat" } network_adapter { type = "bridged" host_interface = "eno1" }

network_adapter { type = "hostonly" host_interface = "vboxnet1" } }

output "IPAddr" { value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1) }

output "IPAddr_2" { value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2) }

On Fri, Oct 28, 2022 at 9:32 AM Nik Stuckenbrock @.***> wrote:

Hey @VoyTechnology https://github.com/VoyTechnology, build proceeds now and resolves in another error. So reading out the guestproperty works now. You could flag a new release or wait until I have investigated the new error message if you want.

— Reply to this email directly, view it on GitHub https://github.com/terra-farm/terraform-provider-virtualbox/issues/149#issuecomment-1294696352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALUP4VY7USCT2GE4ZYRSNY3WFOFSZANCNFSM576YC3WA . You are receiving this because you were mentioned.Message ID: @.*** com>

nikstuckenbrock commented 1 year ago

Hey @mohang6770 , a little bit more communication would be helpful. It looks like you're not using the source version, instead you use the same version as before? Furthermore you're reporting a completely different error message than before. Could you provide more details?

EduardoSantanaSeverino commented 1 year ago

Hi there,

I am still struggling to get this to work, and I am still getting the same error as previously described:

can't convert vbox network to terraform data: No match with get guestproperty output

nikstuckenbrock commented 1 year ago

Hey @EduardoSantanaSeverino,

it would be very nice if you could provide all the information mentioned in the bug report template. Have you tried debugging the provider (after compiling it yourself) as mentioned in the docs? Moreover I would suggest to check your version again. The latest released version does not contain the fix provided in #156, you'll need to use the explicit commit hash to get the latest code. I hope this helps you to analyse/fix your problem,

amnet04 commented 1 year ago

Today I got this error. In my case, the problem was that the vm doesn't have enough memory to start Ubuntu.

edward8e commented 1 month ago

I got this error also. I only saw it when I tried to increase the count from 1 to 2. The VM was able to boot up just fine, but the error showed up before it could finish booting up. I think it was a timeout issue for me.

I instead made each resource boot up with a "depends_on" parameter to the previous resource. It's a workaround for me.