terra-farm / terraform-provider-virtualbox

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

Provider on windows multiple tests #123

Open abdelhaleemahmed opened 2 years ago

abdelhaleemahmed commented 2 years ago

Greetings,

I tried to run the provider on windows 10, form a powershell prompt using the following configurations:

Software: Virtualbox version: 6.1.28r147628 Provider: 0.2.2-alpha.1 Terraform: Terraform v1.0.11 on windows_amd64

Configuration file:

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     = "/DevOps/boxes/bionic20211025.0.0.box"
  #image     = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20210916.0.0/providers/virtualbox.box"
  cpus      = 2
  memory    = "4096 mib"
  #user_data = file("user_data")

  network_adapter {
    type = "nat"
  }

}

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

~

Issue 01: I got the machine up and running and with the NAT configuration, and able to access the internet, but with the following error:

virtualbox_vm.node[0]: Creating...
virtualbox_vm.node[0]: Still creating... [10s elapsed]
╷
│ Error: [ERROR] can't convert vbox network to terraform data: No match with get guestproperty output
│
│   with virtualbox_vm.node[0],
│   on infra.tf line 11, in resource "virtualbox_vm" "node":
│   11: resource "virtualbox_vm" "node" {
│
╵

Changing the configuration to the following and use a hostonly network:

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     = "/DevOps/boxes/bionic20211025.0.0.box"
  #image     = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20210916.0.0/providers/virtualbox.box"
  cpus      = 2
  memory    = "4096 mib"
  #user_data = file("user_data")

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

output "IPAddr" {
  value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)
}
virtualbox_vm.node[0]: Creating...
virtualbox_vm.node[0]: Still creating... [10s elapsed]
╷
│ Error: [ERROR] Starting VM: exit status 1
│
│   with virtualbox_vm.node[0],
│   on infra.tf line 11, in resource "virtualbox_vm" "node":
│   11: resource "virtualbox_vm" "node" {
│
╵

I'm I downing something wrong?

any advice is appreciated, I'm a Linux expert so, I will move my tests to a Linux machine and then try everything again. Moreover I used multiple images with the same results.

VoyTechnology commented 2 years ago

I took the liberty of editing the comment to add syntax highlighting. I hope you don't mind.

abuarbaz commented 2 years ago

I was able to solve this problem by adding the correct hostinterface name. Try to see the hostinterface name and assign that you should be able to create that successfully. Check that in your case how the interface is looking if you try to create a VM manually and assign that interface accordingly.

image

network_adapter {
   type = "bridged"
   host_interface = "Intel(R) Dual Band Wireless-AC 8260"
}
retro97bv commented 4 months ago

It happens exactly the same

terraform { required_providers { virtualbox = { source = "terra-farm/virtualbox" version = "0.2.2-alpha.1" } } } resource "virtualbox_vm" "node" { name = "skyneds" image = "https://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box" cpus = 2 memory = "1024 mib"

network_adapter { type = "nat" } }