Giter Site home page Giter Site logo

terra-farm / terraform-provider-virtualbox Goto Github PK

View Code? Open in Web Editor NEW
323.0 24.0 134.0 394 KB

VirtualBox provider for Terraform

Home Page: https://terra-farm.github.io/provider-virtualbox/

License: MIT License

Go 93.26% Makefile 2.94% HTML 3.80%
terraform terraform-provider virtualbox hacktoberfest

terraform-provider-virtualbox's Introduction

Build Status FOSSA Status Gitter

VirtualBox provider for Terraform

Published documentation is located on the Terraform Registry

Maintainers Needed

We are looking for additional maintainers.

Usage

terraform {
  required_providers {
    virtualbox = {
      source = "terra-farm/virtualbox"
      version = "<latest-tag>"
    }
  }
}

provider "virtualbox" {
  # Configuration options
}

resource "virtualbox_vm" "vm" {
  // ...
}

Example

You can find a practical example in the /examples directory

If you want to contribute documentation changes, see the Contribution guide.

Limitations

  • Experimental provider!
  • We only officially support the latest version of Go, Virtualbox and Terraform. The provider might be compatible and work with other versions but we do not provide any level of support for this due to lack of time.
  • The defaults here are only tested with the vagrant insecure (packer) keys as the login.

Contributors

Special thanks to all contributors, and @ccll for donating the original project to the terra-farm group!

Inspired by terraform-provider-vix

License

FOSSA Status

terraform-provider-virtualbox's People

Contributors

catay avatar ccll avatar damdo avatar dependabot[bot] avatar firebladee avatar fossabot avatar ghouscht avatar iuriimedvedev avatar jayunit100 avatar jpts avatar jskswamy avatar leodotcloud avatar nevill avatar nikstuckenbrock avatar patsevanton avatar pytoshka avatar ringods avatar spurin avatar tylerauerbeck avatar voytechnology avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-virtualbox's Issues

Provisioner "remote-exec/file" seems not working

When I add provisioner section like:

provisioner "file" {
    source      = "scripts/test.sh"
    destination = "/tmp/script.sh"
  }
  provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/script.sh",
      "/tmp/script.sh args",
    ]
  }

The node is provisionned but it failed with error:

Error: Error applying plan:

1 error(s) occurred:

* virtualbox_vm.node: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

The script is not executed.. If I comment my code the node is well provisioned with no error.

vboxnet0 is not found

Could not start the machine ... because the following physical network interfaces were not found:
vboxnet1 (adapter 1)
You can either change the machine's network settings or stop the machine.

apt-cache policy virtualbox

  Installed: 5.2.18-dfsg-2ubuntu18.10.1

terraform --version

+ provider.virtualbox (unversioned)

Error: [ERROR] Starting VM: exit status 1

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

Log:

2019/08/23 13:22:10 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: [ERROR] Starting VM: exit status 1
2019/08/23 13:22:10 [ERROR] <root>: eval: *terraform.EvalSequence, err: [ERROR] Starting VM: exit status 1
2019/08/23 13:23:08 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: [ERROR] Starting VM: exit status 1
2019/08/23 13:23:08 [ERROR] <root>: eval: *terraform.EvalSequence, err: [ERROR] Starting VM: exit status 1
2019/08/23 13:23:08 [TRACE] [walkApply] Exiting eval tree: virtualbox_vm.node[0]```

Terraform config:

resource "virtualbox_vm" "node" {
  count     = 2
  name      = format("node-%02d", count.index + 1)
  image     = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
  cpus      = 2
  memory    = "512 mib"
  user_data = file("user_data")

  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)
}

Static IP Address

Does the Virtualbox provider support configuring a static IP address? I see that other providers are able to do this, so it would make sense to replicate that within this plugin. Just not sure if I'm just looking over it or not.

Unable to set UIID missing command

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 bf3e588 revision.
Is this a bug or I am doing something wrong?

import go-virtualbox

Hi,

Is there a reason why the provider imports 'github.com/pyToshka/go-virtualbox' and not 'github.com/terra-farm/go-virtualbox' ?
The latest seems to be maintained and also contains a proper license.

Happy to submit a PR to get that changed if that makes sense.

Cheers.

Terraform 0.12 Windows Support

Hello,
The last pre-released version has support for unix/linux distribution. When or even if will be available version which will include Windows as it was for previous versions?

Error: Failed to instantiate provider "virtualbox" to obtain schema: Incompatible API version with plugin. Plugin version: 4, Client versions: [5]

$ terraform --version
Terraform v0.12.3
+ provider.virtualbox (unversioned)

main.tf

resource "virtualbox_vm" "node" {
    count = 2
    name = "${format("node-%02d", count.index+1)}"
    url = "https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180420.0.0/providers/virtualbox.box"
    image = "./virtualbox.box"
    cpus = 2

     network_adapter {
       type = "bridged"
       host_interface="en0"
    }
}
$ terraform init
$ terraform plan

Error: Failed to instantiate provider "virtualbox" to obtain schema: Incompatible API version with plugin. Plugin version: 4, Client versions: [5]

exit status 1 - hostonly network

When trying to set the network adapter to hostonly, terraform apply ends in exit status 1. Here is the output from the debug log:

2018-03-30T23:01:12.639-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-51046-vbm.go:45: executing: VBoxManage modifyvm node-02 --firmware bios --bioslogofadein off --bioslogofadeout off --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux_64 --cpus 2 --memory 976 --vram 20 --acpi on --ioapic on --rtcuseutc on --cpuhotplug off --pae on --longmode on --hpet off --hwvirtex on --triplefaultreset off --nestedpaging on --largepages on --vtxvpid on --vtxux on --accelerate3d off --boot1 disk --boot2 none --boot3 none --boot4 none --nic1 hostonly --nictype1 82545EM --cableconnected1 on --hostonlyadapter1 en0
2018-03-30T23:01:12.711-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-51046-vbm.go:75: executing: VBoxManage showvminfo node-02 --machinereadable
2018-03-30T23:01:12.799-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-51046-vbm.go:45: executing: VBoxManage startvm node-02 --type headless
2018-03-30T23:01:13.118-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-51046-resource_vm.go:333: [ERROR] Start VM: exit status 1
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalWriteState
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalIf
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalWriteState
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalWriteDiff
2018/03/30 23:01:13 [TRACE] root: eval: *terraform.EvalApplyPost
2018/03/30 23:01:13 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* virtualbox_vm.node.1: exit status 1
2018/03/30 23:01:13 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* virtualbox_vm.node.1: exit status 1

My terraform tf file is based off the one provided in example, with the only change being

    network_adapter {
        type = "hostonly",
        host_interface = "en0",
    }

This works without any issue if I leave the network type as bridged.

Why on CentOS guest get /VirtualBox/GuestInfo/Net/0/MAC?

Why cannot get /VirtualBox/GuestInfo/Net/0/MAC?

example.tf

resource "virtualbox_vm" "node" {
  count     = 1
  name      = format("node-%02d", count.index + 1)
  image     = "CentOS-7-x86_64-Vagrant-1907_01.VirtualBox.box"
  cpus      = 2
  memory    = "512 mib"
  user_data = file("user_data")

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

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

wget https://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-1907_01.VirtualBox.box
terraform apply

Output
2019-08-26T13:19:47.414+0600 [DEBUG] plugin.terraform-provider-virtualbox: pid-29909-vbm.go:60: executing: VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/MAC

Full output
https://gist.github.com/patsevanton/23f20ffe041719c2a3c2e5eca69b4b8e

Topic on forums.virtualbox.org
https://forums.virtualbox.org/viewtopic.php?f=3&t=94455

How to specify login credentials

It would be useful to document how to specify login credentials.

I've booted a couple of nodes using the example.tf but don't know how to specify login credentials or login with the example box.

I tried adding a connection construct within the resource without success.

Is this possible with this provider or are we obliged to prepare the box/image in advance with known credentials?

  connection {
      type     = "ssh"

      #user     = "root"
      #password = "${var.root_password}"

      user     = "ubuntu"
      password = "test1234"
      host_key = "${file("/home/mjb/.ssh/id_rsa.pub")}"
      public_key = "${file("/home/mjb/.ssh/id_rsa.pub")}"
  }

Installation Instructions

Hello I hope this is the right place to put this. I found the installation instructions in the readme incomplete. I think they should be expanded a bit.
I am working on a windows 10 device with terraform, vagrant, virtualbox and go installed. After running the go get instruction in the readme(go get github.com/terra-farm/terraform-provider-virtualbox), I had to copy the binary from the $GO_HOME/bin folder to the following location "C:\Users_$(whoami)_\AppData\Roaming\terraform.d\plugins\windows_amd64" (please note to replace the $(whoami) variable with the appropriate username) before terraform could recognize the provider.

Example should be updated for xenial LTS

The real issue here is that I've tried reproducing the example using a Xenial image, e.g.
https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180306.0.0/providers/virtualbox.box

but these consistently fail to apply.

I'm seeing the following in the trace output:

2018-04-04T22:52:58.571+0200 [DEBUG] plugin.terraform-provider-virtualbox: pid-11790-image.go:51: exit status 2
2018-04-04T22:52:58.571+0200 [DEBUG] plugin.terraform-provider-virtualbox: pid-11790-resource_vm.go:212: [ERROR] Unpack image ./virtualbox-xenial-16.04.box: exit status 2

Any idea what's happening?

Error using provider docker

Hi,

I successfully have been able to create virtualbox machine with this provider, however when I try to use the provider docker with the IP created by this provider I have the following error:
provider.docker: Error pinging Docker server: cannot connect to Docker endpoint

Here is the code I used:

# Configure the Docker provider
provider "docker" {
  # host = "unix:///var/run/docker.sock" # Working but not inside the virtualbox machine
  # host = "tcp://${element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)}:2376/" # Not working
  host = "tcp://${element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)}:2375/"
}

resource "docker_image" "ubuntu" {
  name = "ubuntu:latest"
}

# Create a container
resource "docker_container" "foo" {
  image = "${docker_image.ubuntu.latest}"
  name  = "foo"
}

Any idea why it's failing? Or I should use remote-exec instead?

Thx

Virtual disks should be their own resources

The resource_vm is responsible for the whole lifetime of a VM. We should detach the responsibility of creating the virtual disk and delegate it to resource_disk, which can be controlled independently of the VM.

Terraform apply fails due to --synthcpu setting

Running the example with the provided ubuntu image fails:

2 error(s) occurred:
* virtualbox_vm.node.1: exit status 1
* virtualbox_vm.node.0: exit status 1

Setting Terraform tracing gives the output file with the following lines:

... [snip] ...
2016/01/12 11:43:43 [DEBUG] terraform-provider-virtualbox: pid-21335-vbm.go:45: executing: VBoxManage modifyvm node-01 ... [snip] ... --synthcpu off ...
...
2016/01/12 11:43:43 [DEBUG] terraform-provider-virtualbox: VBoxManage: error: Unknown option: --synthcpu
2016/01/12 11:43:43 [DEBUG] terraform-provider-virtualbox: pid-21335-resource_vm.go:215: [ERROR] Setup VM properties: exit status 1

synthcpu is no longer supported in VirtualBox 5. Docker also ran into this issue, ref docker/machine#1496, and removed that flag.

This flag should be removed, and the code should use default VBoxManage flags as much as possible.

Plugin reinitialization required. Please run "terraform init".

Version

Terraform: v0.11.10
Terraform-provider-virtualbox: latest installed using ()

Steps to reproduce

  • Execute commands as defined under examples README section
cd $GOPATH/src/github.com/terra-form/terraform-provider-virtualbox/examples
terraform plan
Plugin reinitialization required. Please run "terraform init".
Reason: Could not satisfy plugin requirements.

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

1 error(s) occurred:

* provider.virtualbox: no suitable version installed
  version requirements: "(any version)"
  versions installed: none

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints from each module, run "terraform providers".


Error: error satisfying plugin requirements
  • Run Terraform init
terraform init

Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...

Provider "virtualbox" not available for installation.

A provider named "virtualbox" could not be found in the official repository.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
    terraform.d/plugins/darwin_amd64

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".

Provided example is giving - Nonexistent host networking interface, name 'en0' (VERR_INTERNAL_ERROR)

Terraform v0.11.5

  • provider.virtualbox (unversioned)

Using provider.virtualbox built with go1.9.2 built from current source sha: 0e96845

Using 5.2.8-121009Ubuntuxenial.

Running TF_LOG=1 terraform apply
gives:

2018-04-03T19:13:39.280+0200 [DEBUG] plugin.terraform-provider-virtualbox: pid-6636-vbm.go:45: executing: VBoxManage startvm node-01 --type headless
2018-04-03T19:13:39.474+0200 [DEBUG] plugin.terraform-provider-virtualbox: pid-6636-resource_vm.go:333: [ERROR] Start VM: exit status 1

Running VBoxManage startvm node-01 --type headless

gives:

Waiting for VM "node-01" to power on...
VBoxManage: error: Nonexistent host networking interface, name 'en0' (VERR_INTERNAL_ERROR)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

Terraform v0.7.7 support?

W/ Terraform v0.7.7 installed and lasted compiled executable.

โžœ terraform-test terraform plan
Error configuring: 1 error(s) occurred:

  • Unrecognized remote plugin message: 2|unix|/var/folders/4z/vg3f9q9n35v96126f23b6dz8lzdwds/T/tf-plugin326334445

This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.

Sometime it cannot find NICs address respectively

Suppose my Virtualbox have following output.

From showvminfo

$ VBoxManage showvminfo "master-01" --machinereadable
name="master-01"
memory=1024
cpus=2
pae="on"
VMState="running"
hostonlyadapter1="vboxnet1"
macaddress1="0800275BAF21"
cableconnected1="on"
nic1="hostonly"
nictype1="82545EM"
nicspeed1="0"
natnet2="nat"
macaddress2="0800274A2EA2"
cableconnected2="on"
nic2="nat"
nictype2="82545EM"
nicspeed2="0"
nic3="none"
nic4="none"
nic5="none"
nic6="none"
nic7="none"
nic8="none"
GuestMemoryBalloon=0
GuestOSType="Linux26_64"
GuestAdditionsRunLevel=2
GuestAdditionsVersion="6.0.14 r133895"
GuestAdditionsFacility_VirtualBox Base Driver=50,1571759712632
GuestAdditionsFacility_VirtualBox System Service=50,1571759720710
GuestAdditionsFacility_Seamless Mode=0,1571759712629
GuestAdditionsFacility_Graphics Mode=0,1571759712629

... more properties are cut off

From guest property

$ VBoxManage guestproperty enumerate master-01 --patterns "/VirtualBox/GuestInfo/Net*"
Name: /VirtualBox/GuestInfo/Net/0/MAC, value: 0800274A2EA2, timestamp: 1571759720723377000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 10.0.3.15, timestamp: 1571759720723226000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/Netmask, value: 255.255.255.0, timestamp: 1571759720723342000, flags:
Name: /VirtualBox/GuestInfo/Net/0/Status, value: Up, timestamp: 1571759720723419000, flags:
Name: /VirtualBox/GuestInfo/Net/0/Name, value: eth0, timestamp: 1571759720723448000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/Broadcast, value: 10.0.3.255, timestamp: 1571759720723308000, flags:

Name: /VirtualBox/GuestInfo/Net/1/Name, value: docker0, timestamp: 1571759720723876000, flags:
Name: /VirtualBox/GuestInfo/Net/1/MAC, value: 0242BF5B1B9D, timestamp: 1571759720723772000, flags:
Name: /VirtualBox/GuestInfo/Net/1/V4/IP, value: 172.17.0.1, timestamp: 1571759720723477000, flags:
Name: /VirtualBox/GuestInfo/Net/1/V4/Netmask, value: 255.255.0.0, timestamp: 1571759720723594000, flags:
Name: /VirtualBox/GuestInfo/Net/1/Status, value: Up, timestamp: 1571759720723842000, flags:
Name: /VirtualBox/GuestInfo/Net/1/V4/Broadcast, value: 172.17.255.255, timestamp: 1571759720723514000, flags:

Name: /VirtualBox/GuestInfo/Net/2/Status, value: Up, timestamp: 1571759720724350000, flags:
Name: /VirtualBox/GuestInfo/Net/2/Name, value: eth1, timestamp: 1571759720724414000, flags:
Name: /VirtualBox/GuestInfo/Net/2/MAC, value: 0800275BAF21, timestamp: 1571759720724187000, flags:
Name: /VirtualBox/GuestInfo/Net/2/V4/IP, value: 192.168.99.112, timestamp: 1571759720723908000, flags:
Name: /VirtualBox/GuestInfo/Net/2/V4/Netmask, value: 255.255.255.0, timestamp: 1571759720724096000, flags:
Name: /VirtualBox/GuestInfo/Net/2/V4/Broadcast, value: 192.168.99.255, timestamp: 1571759720723946000, flags:

Name: /VirtualBox/GuestInfo/Net/Count, value: 3, timestamp: 1571760671544746000, flags:

Notice that one more interface docker0 created after VM started.

here in code

for i := 0; i < len(vm.NICs); i++ {

we only iterate over the number of physical interfaces, which possibly cannot find the interface IP address in the 3rd place.
Also, it results in returning early and resource network_adapter cannot be set.

osNic, ok := osNicMap[nic.MacAddr]
if !ok {
return nil
}

My proposal would be

  1. in terra-farm/go-virtualbox, add a new method to enumerate all the runtime interfaces based on get the number of NICs via guestproperty /VirtualBox/GuestInfo/Net/Count
  2. fix method netVboxToTf by calling the new method

Virtual machine can not boot after create by teraform

HI Guys,

I'm new of Teraform, i use example config to run create virtual machine in virtualbox.
The machine created but can't boot to OS.
Error on Teraform cli:
Error: Error applying plan:

1 error(s) occurred:

  • virtualbox_vm.node: 1 error(s) occurred:

  • virtualbox_vm.node: [ERROR] Wait VM until ready: waiting for VM (node-01) to become ready: timeout while waiting for state to become 'yes' (timeout: 5m0s)

And error on virtualbox:
FATAL: Could not read from the boot medium! System halted
Where 're my missing? My virtualbox version 6.0 and Tera version 0.11.13

Second network card don`t assign IP address

main.tf

resource "virtualbox_vm" "node" {
  count     = 1
  name      = format("node-%02d", count.index + 1)
  image     = "bento-centos-7.box"
  cpus      = 1
  memory    = "512 mib"

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

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

Get comand virtualbox from log:

VBoxManage list vms
VBoxManage createvm --name node-01 --register --basefolder /home/user/.terraform/virtualbox/machine
VBoxManage showvminfo node-01 --machinereadable
VBoxManage clonehd /home/user/.terraform/virtualbox/gold/bento-centos-7/centos-7.6-x86_64-disk001.vmdk /home/user/.terraform/virtualbox/machine/node-01/centos-7.6-x86_64-disk001.vmdk
VBoxManage storagectl node-01 --name SATA --add sata --portcount 2 --controller IntelAHCI --hostiocache on --bootable on
VBoxManage storageattach node-01 --storagectl SATA --port 0 --device 0 --type hdd --medium /home/user/.terraform/virtualbox/machine/node-01/centos-7.6-x86_64-disk001.vmdk
VBoxManage modifyvm node-01 --firmware bios --bioslogofadein off --bioslogofadeout off --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux_64 --cpus 1 --memory 512 --vram 20 --acpi on --ioapic on --rtcuseutc on --cpuhotplug off --pae on --longmode on --hpet off --hwvirtex on --triplefaultreset off --nestedpaging on --largepages on --vtxvpid on --vtxux on --accelerate3d off --boot1 disk --boot2 none --boot3 none --boot4 none --nic1 hostonly --nictype1 82545EM --cableconnected1 on --hostonlyadapter1 vboxnet0 --nic2 hostonly --nictype2 82545EM --cableconnected2 on --hostonlyadapter2 vboxnet1
VBoxManage showvminfo node-01 --machinereadable
VBoxManage startvm node-01 --type headless
VBoxManage showvminfo 769bbafb-9cd9-4957-9cca-e58a00ee6a9c --machinereadable
VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/MAC
VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/Status
VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/V4/IP
VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/1/MAC

Don`t have ifcfg-eth1

Terraform 0.10.7 not working with Terraform init

Terraform Version
Terraform v0.10.7

Affected Resource(s)
providers
modules
core

Terraform Configuration Files
terraform {
backend "s3" {
bucket = xxx-ate"
key = "xxx-yyy.tfstate"
workspace_key_prefix = "xx/yy"
dynamodb_table = "xx-lock"
region = "us-east-1"
}
}

Expected Behavior
Expected to see a full run happen aActual Behavior
Fails to initialize terraform (both plugins and modules)

Error:
Provider "provider" not available for installation.

A provider named "provider" could not be found in the official repository.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
terraform.d/plugins/linux_386

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".

Provider "module" not available for installation.

A provider named "module" could not be found in the official repository.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
terraform.d/plugins/linux_386

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".

Steps to Reproduce
terraform init

References
N/A

Git repos not meeting constraints during dep ensure

Following the "How to build from source" steps, I can't seem to get dep ensure to work. First github.com/dustin/go-humanize is not allowed by constraints.

Gopkg.lock is out of sync with Gopkg.toml and project imports:
github.com/terra-farm/terraform-provider-virtualbox/virtualbox: imported or required, but missing from Gopkg.lock's input-imports

Root project is "terraform-provider-virtualbox"
 2 transitively valid internal packages
 9 external packages imported from 6 projects
(0)   โœ“ select (root)
(1)     ? attempt github.com/dustin/go-humanize with 1 pkgs; at least 1 versions to try
(1)         try github.com/dustin/[email protected]
(1)     โœ—   unexpected error while defensively updating submodules: fatal: 'submodule' appears to be a git command, but we were not
(1)       able to execute it. Maybe git-submodule is broken?
(1)       : command failed: [git submodule update --init --recursive]: exit status 128
(1)         try github.com/dustin/go-humanize@master
(2)     โœ—   github.com/dustin/go-humanize@master not allowed by constraint ^1.0.0:
(2)         ^1.0.0 from (root)
(1)       โ† no more versions of github.com/dustin/go-humanize to try; begin backtrack
  โœ— solving failed

Solver wall times by segment:
         b-list-pkgs: 1.8030712s
     b-list-versions: 1.2778305s
     b-source-exists: 253.9108ms
             satisfy:   4.8661ms
         select-root:   2.9269ms
               other:   1.9501ms
            new-atom:      967ยตs
  b-deduce-proj-root:         0s

  TOTAL: 3.3455226s

Solving failure: No versions of github.com/dustin/go-humanize met constraints:
        v1.0.0: unexpected error while defensively updating submodules: fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?
: command failed: [git submodule update --init --recursive]: exit status 128
        master: Could not introduce github.com/dustin/go-humanize@master, as it is not allowed by constraint ^1.0.0 from project terraform-provider-virtualbox.

I noticed that the lock and toml files were out of sync, so I deleted gopkg.lock, gopkg.toml, and go/pkg/dep/sources.

dep init -v:
Getting direct dependencies...
Checked 9 directories for packages.
Found 6 direct dependencies.
Root project is "terraform-provider-virtualbox"
 2 transitively valid internal packages
 9 external packages imported from 6 projects
(0)   โœ“ select (root)
(1)     ? attempt github.com/pyToshka/go-virtualbox with 1 pkgs; 1 versions to try
(1)         try github.com/pyToshka/go-virtualbox@master
(1)     โœ—   unexpected error while defensively updating submodules: fatal: 'submodule' appears to be a git command, but we were not
(1)       able to execute it. Maybe git-submodule is broken?
(1)       : command failed: [git submodule update --init --recursive]: exit status 128
(1)       โ† no more versions of github.com/pyToshka/go-virtualbox to try; begin backtrack
  โœ— solving failed

Solver wall times by segment:
     b-list-versions: 9.2838633s
         b-list-pkgs: 1.9447826s
         select-root:   1.9484ms
            new-atom:    976.7ยตs
               other:    976.5ยตs
     b-source-exists:         0s
             satisfy:         0s
  b-deduce-proj-root:         0s

  TOTAL: 11.2325475s

init failed: unable to solve the dependency graph: Solving failure: No versions of github.com/pyToshka/go-virtualbox met constraints:
        master: unexpected error while defensively updating submodules: fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?
: command failed: [git submodule update --init --recursive]: exit status 128

And then github.com/pyToshka/go-virtualbox would not meet constraints. I'm not sure if this is a problem with the repos or my local set up, but I'd appreciate any insight.

Resource for ssh key logins.

I'm new to Terraform, glad to have a virtualbox provider for testing. It all installed it just fine,only issue was having to change the Virtualbox instances to nat from bridged on Debian host. But having the two example nodes installed ,how can I import my ssh keys to each of these nodes so I can log into them? This is not the vagrant version,just the Ubuntu version provided. Also, I would also like to create my own image to use with Terraform and would like to know the syntax for adding my keys into the tf file.

Move to a GitHub org to continue maintenance?

I almost certainly don't have the experience to maintain this myself, but I think we could move this repo to an org like sous-chefs does for chef cookbooks. Then I can help out anyone wanting to contribute.

If that doesn't sound ideal, please let me know! I'd hate for this project to go unmaintained.

What license is this code under?

Please be aware that without a license, it is very difficult for others to legally use or reproduce your code. I'd recommand Apache v2 if you're not sure what license to choose.

VM Fails to become read

MacOS High Sierra
Version 5.2.18 r124319 (Qt5.6.3)

Using the sample, with count = 1, The instances are stood up, but repeated failures to get "showvminfo" causes overall failure with these messages at the end of the debug log:

2018-09-21T09:07:33.606-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:75: executing: VBoxManage showvminfo 9609356b-e960-42d0-a1fe-81c27ccbf6b1 --machinereadable
2018-09-21T09:07:33.688-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:60: executing: VBoxManage getextradata node-01 user_data
2018-09-21T09:07:33.727-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:60: executing: VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/MAC
2018-09-21T09:07:33.767-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-state.go:193: [TRACE] Waiting 10s before next try
2018-09-21T09:07:43.769-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:75: executing: VBoxManage showvminfo 9609356b-e960-42d0-a1fe-81c27ccbf6b1 --machinereadable
2018-09-21T09:07:43.864-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:60: executing: VBoxManage getextradata node-01 user_data
2018-09-21T09:07:43.904-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-vbm.go:60: executing: VBoxManage guestproperty get node-01 /VirtualBox/GuestInfo/Net/0/MAC
2018-09-21T09:07:43.944-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-state.go:193: [TRACE] Waiting 10s before next try
2018-09-21T09:07:46.490-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-state.go:218: [WARN] WaitForState timeout after 5m0s
2018-09-21T09:07:46.490-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-state.go:219: [WARN] WaitForState starting 30s refresh grace period
2018-09-21T09:07:46.491-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-resource_vm.go:343: [ERROR] Wait VM unitl ready: Error waiting for VM (node-01) to become ready: timeout while waiting for state to become 'yes' (timeout: 5m0s)
2018/09/21 09:07:46 [DEBUG] plugin: waiting for all plugin processes to complete...
2018-09-21T09:07:46.502-0400 [DEBUG] plugin.terraform-provider-virtualbox: pid-12628-rpc_server.go:48: [ERR] plugin: plugin server: accept unix /var/folders/v0/v9xm5xps3gschkk3gfp0snbsc3d7ph/T/plugin676224955: use of closed network connection
2018-09-21T09:07:46.503-0400 [DEBUG] plugin: plugin process exited: path=/Users/ndb338/Virtualbox/terraform-provider-virtualbox

I would like to note that I am willing to help with this project if you need it, but I have had some issues with your "build from source" directions. Some things I may be willing to add are the ability to handle 7zip files for images, testing to see if the image is newer than the directory contents, and automatic key refresh if keys are provided and the image has the default vagrent keys.

Error using terraform on windows

C:\terraform\one>..\terraform.exe apply
2018/07/30 15:22:04 [INFO] Terraform version: 0.11.7  41e50bd32a8825a84535e353c3674af8ce799161
2018/07/30 15:22:04 [INFO] Go runtime version: go1.10.1
2018/07/30 15:22:04 [INFO] CLI args: []string{"C:\\terraform\\terraform.exe", "apply"}
2018/07/30 15:22:04 [DEBUG] Attempting to open CLI config file: C:\Users\User\AppData\Roaming\terraform.rc
2018/07/30 15:22:04 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/07/30 15:22:04 [INFO] CLI command args: []string{"apply"}
2018/07/30 15:22:04 [INFO] command: empty terraform config, returning nil
2018/07/30 15:22:04 [DEBUG] command: no data state file found for backend config
2018/07/30 15:22:04 [DEBUG] New state was assigned lineage "4e8003a1-5b1c-f5c5-0662-497651b3279b"
2018/07/30 15:22:04 [INFO] command: backend initialized: <nil>
2018/07/30 15:22:04 [DEBUG] checking for provider in "."
2018/07/30 15:22:04 [DEBUG] checking for provider in "C:\\terraform"
2018/07/30 15:22:04 [WARN] found legacy provider "terraform-provider-virtualbox_windows_amd64.exe"
2018/07/30 15:22:04 [DEBUG] checking for provider in ".terraform\\plugins\\windows_amd64"
2018/07/30 15:22:04 [DEBUG] checking for provider in "C:\\Users\\User\\AppData\\Roaming\\terraform.d\\plugins"
2018/07/30 15:22:04 [DEBUG] checking for provider in "C:\\Users\\User\\AppData\\Roaming\\terraform.d\\plugins\\windows_amd64"
2018/07/30 15:22:04 [WARN] found legacy provider "terraform-provider-virtualbox.exe"
2018/07/30 15:22:04 [DEBUG] found valid plugin: "virtualbox_windows_amd64", "0.0.0", "C:\\terraform\\terraform-provider-virtualbox_windows_amd64.exe"
2018/07/30 15:22:04 [DEBUG] found valid plugin: "virtualbox", "0.0.0", "C:\\Users\\User\\AppData\\Roaming\\terraform.d\\plugins\\windows_amd64\\terraform-provider-virtualbox.exe"
2018/07/30 15:22:04 [DEBUG] checking for provisioner in "."
2018/07/30 15:22:04 [DEBUG] checking for provisioner in "C:\\terraform"
2018/07/30 15:22:04 [DEBUG] checking for provisioner in ".terraform\\plugins\\windows_amd64"
2018/07/30 15:22:04 [DEBUG] checking for provisioner in "C:\\Users\\User\\AppData\\Roaming\\terraform.d\\plugins"
2018/07/30 15:22:04 [DEBUG] checking for provisioner in "C:\\Users\\User\\AppData\\Roaming\\terraform.d\\plugins\\windows_amd64"
2018/07/30 15:22:04 [INFO] command: backend <nil> is not enhanced, wrapping in local
2018/07/30 15:22:04 [INFO] backend/local: starting Apply operation
2018/07/30 15:22:04 [DEBUG] New state was assigned lineage "f764831d-48e5-1155-c359-466dfab41645"
2018/07/30 15:22:04 [INFO] terraform: building graph: GraphTypeInput
2018/07/30 15:22:04 [DEBUG] Resource state not found for "virtualbox_vm.node": virtualbox_vm.node
2018/07/30 15:22:04 [DEBUG] Starting graph walk: walkInput
2018-07-30T15:22:04.804-0400 [DEBUG] plugin: waiting for RPC address: path=C:\Users\User\AppData\Roaming\terraform.d\plugins\windows_amd64\terraform-provider-virtualbox.exe
2018-07-30T15:22:04.835-0400 [DEBUG] plugin.terraform-provider-virtualbox.exe: pid-7560-server.go:52: [ERR] plugin init: strconv.ParseInt: parsing "": invalid syntax
2018-07-30T15:22:04.848-0400 [DEBUG] plugin: plugin process exited: path=C:\Users\User\AppData\Roaming\terraform.d\plugins\windows_amd64\terraform-provider-virtualbox.exe
2018/07/30 15:22:04 [ERROR] root: eval: *terraform.EvalInitProvider, err: plugin exited before we could connect
2018/07/30 15:22:04 [ERROR] root: eval: *terraform.EvalSequence, err: plugin exited before we could connect
2018/07/30 15:22:04 [DEBUG] plugin: waiting for all plugin processes to complete...

Error: Error asking for user input: 1 error(s) occurred:

* provider.virtualbox: plugin exited before we could connect

virtualbox_vm.node: exit status 1

Hey there,

I use Terraform v0.6.7 installed via brew and the latest provider on El Capitan.
My terraform looks like this:

$ cat virtualbox.tf
resource "virtualbox_vm" "node" {
    count = 1
    name = "${format("node-%02d", count.index+1)}"

    image = "/Users/kniepbert/Downloads/ubuntu-15.04.tar.xz"
    cpus = 1
    memory = "512mib"

    network_adapter {
        type = "nat"
    }

    #network_adapter {
    #    type = "bridged"
    #    host_interface = "en0"
    #}
}

#output "IPAddr" {
#    # Get the IPv4 address of the bridged adapter (the 2nd one) on 'node-02'
#    value = "${element(virtualbox_vm.node.*.network_adapter.1.ipv4_address, 1)}"
#}

I got this error:

$ terraform apply
virtualbox_vm.node: Creating...
  cpus:                                     "" => "1"
  image:                                    "" => "/Users/kniepbert/Downloads/ubuntu-15.04.tar.xz"
  memory:                                   "" => "512mib"
  name:                                     "" => "node-01"
  network_adapter.#:                        "" => "1"
  network_adapter.0.device:                 "" => "IntelPro1000MTServer"
  network_adapter.0.ipv4_address:           "" => "<computed>"
  network_adapter.0.ipv4_address_available: "" => "<computed>"
  network_adapter.0.mac_address:            "" => "<computed>"
  network_adapter.0.status:                 "" => "<computed>"
  network_adapter.0.type:                   "" => "nat"
  status:                                   "" => "running"
Error applying plan:

1 error(s) occurred:

* virtualbox_vm.node: exit status 1

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Any idea?

Replace dep with Go Modules

Originally I have created #30, which was the most up to date dependency management software at the time. But since then Go Modules came out. Go 1.11 added preliminary support for it, so I think we should look at potentially replacing dep with it.

Below are the steps which are necessary to make go modules work and deprecate go dep.

  • Add go.mod files to the repo - #36
  • Use Go 1.11.4 in Travis - #37
  • Switch to use go modules in .travis.yml - #43
  • Remove Gopkg.toml and Gopkg.lock - 8af001e

No Valid Documentaiton

I guess you already had guy suggesting this, but realy: you need to write down how you to use your piece of software. I've been on this for few hours already and can't make it work.

Prepare for v1.0

The purpose of this issue is to collect feedback and track requirements for v1.0.0 release, designed for Terraform v0.12. This issue would be updated based on the feedback, and when consensus is reached as to what should be in v1.0.0, the issue would be locked, updated when a particular point is done and closed when the release is available. Additionally, a milestone would be created to track progress.

Error using provided example

Using the provided example, I get the following output using Terraform 0.6.6 and the current compiled version of terraform-provider-virtualbox

virtualbox_vm.node.0: Creating...
  cpus:                                     "" => "2"
  image:                                    "" => "~/ubuntu-15.04.tar.xz"
  memory:                                   "" => "512mib"
  name:                                     "" => "node-01"
  network_adapter.#:                        "" => "2"
  network_adapter.0.device:                 "" => "IntelPro1000MTServer"
  network_adapter.0.ipv4_address:           "" => "<computed>"
  network_adapter.0.ipv4_address_available: "" => "<computed>"
  network_adapter.0.mac_address:            "" => "<computed>"
  network_adapter.0.status:                 "" => "<computed>"
  network_adapter.0.type:                   "" => "nat"
  network_adapter.1.device:                 "" => "IntelPro1000MTServer"
  network_adapter.1.host_interface:         "" => "en0"
  network_adapter.1.ipv4_address:           "" => "<computed>"
  network_adapter.1.ipv4_address_available: "" => "<computed>"
  network_adapter.1.mac_address:            "" => "<computed>"
  network_adapter.1.status:                 "" => "<computed>"
  network_adapter.1.type:                   "" => "bridged"
  status:                                   "" => "running"
virtualbox_vm.node.1: Creating...
  cpus:                                     "" => "2"
  image:                                    "" => "~/ubuntu-15.04.tar.xz"
  memory:                                   "" => "512mib"
  name:                                     "" => "node-02"
  network_adapter.#:                        "" => "2"
  network_adapter.0.device:                 "" => "IntelPro1000MTServer"
  network_adapter.0.ipv4_address:           "" => "<computed>"
  network_adapter.0.ipv4_address_available: "" => "<computed>"
  network_adapter.0.mac_address:            "" => "<computed>"
  network_adapter.0.status:                 "" => "<computed>"
  network_adapter.0.type:                   "" => "nat"
  network_adapter.1.device:                 "" => "IntelPro1000MTServer"
  network_adapter.1.host_interface:         "" => "en0"
  network_adapter.1.ipv4_address:           "" => "<computed>"
  network_adapter.1.ipv4_address_available: "" => "<computed>"
  network_adapter.1.mac_address:            "" => "<computed>"
  network_adapter.1.status:                 "" => "<computed>"
  network_adapter.1.type:                   "" => "bridged"
  status:                                   "" => "running"
Error applying plan:

2 error(s) occurred:

* virtualbox_vm.node.0: user: Current not implemented on linux/amd64
* virtualbox_vm.node.1: user: Current not implemented on linux/amd64

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

[ERROR] Clone *.iso and *.dmg (provided example)

Host: MacOS Mojave 10.14.02
Terraform: v0.11.11
VirtualBox: 6.0

Using the provided example I am getting the following error:

2019-01-08T22:22:36.264+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-vbm.go:45: executing: VBoxManage storagectl node-02 --name SATA --add sata --portcount 2 --controller IntelAHCI --hostiocache on --bootable on
2019-01-08T22:22:36.342+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-vbm.go:45: executing: VBoxManage storageattach node-02 --storagectl SATA --port 0 --device 0 --type hdd --medium /Users/imperator/.terraform/virtualbox/machine/node-02/packer-ubuntu-18.04-amd64-disk001.vmdk
2019-01-08T22:22:36.404+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-resource_vm.go:302: [ERROR] Clone *.iso and *.dmg to VM folder: exit status 1
2019/01/08 22:22:36 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* virtualbox_vm.node.1: exit status 1
2019/01/08 22:22:36 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* virtualbox_vm.node.1: exit status 1
2019/01/08 22:22:36 [TRACE] [walkApply] Exiting eval tree: virtualbox_vm.node[1]
2019-01-08T22:22:53.255+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-vbm.go:45: executing: VBoxManage storagectl node-01 --name SATA --add sata --portcount 2 --controller IntelAHCI --hostiocache on --bootable on
2019-01-08T22:22:53.337+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-vbm.go:45: executing: VBoxManage storageattach node-01 --storagectl SATA --port 0 --device 0 --type hdd --medium /Users/imperator/.terraform/virtualbox/machine/node-01/packer-ubuntu-18.04-amd64-disk001.vmdk
2019-01-08T22:22:53.396+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-resource_vm.go:302: [ERROR] Clone *.iso and *.dmg to VM folder: exit status 1
2019/01/08 22:22:53 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* virtualbox_vm.node.0: exit status 1
2019/01/08 22:22:53 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* virtualbox_vm.node.0: exit status 1
2019/01/08 22:22:53 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-01-08T22:22:53.427+0100 [DEBUG] plugin.terraform-provider-virtualbox: pid-19728-rpc_server.go:48: [ERR] plugin: plugin server: accept unix /var/folders/6m/y_dfhm5x6lg5qklhzf78b6v00000gn/T/plugin479546207: use of closed network connection
2019-01-08T22:22:53.429+0100 [DEBUG] plugin: plugin process exited: path=/Users/imperator/.terraform.d/plugins/darwin_amd64/terraform-provider-virtualbox

NAT interface have equal IP address on all virtualbox machine

Box https://vagrantcloud.com/geerlingguy/boxes/centos7/versions/1.2.16/providers/virtualbox.box

Terraform config

resource "virtualbox_vm" "node" {
  count     = 3
  name      = format("node%02d", count.index + 1)
  image     = "virtualbox.box"
  cpus      = 1
  memory    = "2048 mib"

  network_adapter {
    type = "nat"
  }

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

}

terraform show

# virtualbox_vm.node[0]:
resource "virtualbox_vm" "node" {
    cpus   = 1
    id     = "8bf98ea2-8492-45d5-979e-8ad8938bf2c2"
    image  = "virtualbox.box"
    memory = "2.0 gib"
    name   = "node01"
    status = "running"

    network_adapter {
        device                 = "IntelPro1000MTServer"
        ipv4_address           = "10.0.2.15"
        ipv4_address_available = "yes"
        mac_address            = "08002785549C"
        status                 = "up"
        type                   = "nat"
    }
    network_adapter {
        device                 = "IntelPro1000MTServer"
        host_interface         = "vboxnet1"
        ipv4_address           = "192.168.57.3"
        ipv4_address_available = "yes"
        mac_address            = "080027265D28"
        status                 = "up"
        type                   = "hostonly"
    }
}

# virtualbox_vm.node[1]:
resource "virtualbox_vm" "node" {
    cpus   = 1
    id     = "620a7195-4e1b-49be-8295-13739352f4d4"
    image  = "virtualbox.box"
    memory = "2.0 gib"
    name   = "node02"
    status = "running"

    network_adapter {
        device                 = "IntelPro1000MTServer"
        ipv4_address           = "10.0.2.15"
        ipv4_address_available = "yes"
        mac_address            = "08002795B91B"
        status                 = "up"
        type                   = "nat"
    }
    network_adapter {
        device                 = "IntelPro1000MTServer"
        host_interface         = "vboxnet1"
        ipv4_address           = "192.168.57.6"
        ipv4_address_available = "yes"
        mac_address            = "080027F6A8B9"
        status                 = "up"
        type                   = "hostonly"
    }
}

# virtualbox_vm.node[2]:
resource "virtualbox_vm" "node" {
    cpus   = 1
    id     = "ab2e09b6-8993-4445-afd5-467beecca59d"
    image  = "virtualbox.box"
    memory = "2.0 gib"
    name   = "node03"
    status = "running"

    network_adapter {
        device                 = "IntelPro1000MTServer"
        ipv4_address           = "10.0.2.15"
        ipv4_address_available = "yes"
        mac_address            = "08002724A15B"
        status                 = "up"
        type                   = "nat"
    }
    network_adapter {
        device                 = "IntelPro1000MTServer"
        host_interface         = "vboxnet1"
        ipv4_address           = "192.168.57.5"
        ipv4_address_available = "yes"
        mac_address            = "080027F9123D"
        status                 = "up"
        type                   = "hostonly"
    }
}

Physical network interfaces should be their own resources

Physical network interfaces should be their own datasource and resource.

In case of a datasource, at plan and apply, the interface is looked up in the environment and when not there, it can be flagged.

In case of a resource, the network interface can be created first before it is used by a VM. Again, we have a clear dependency here.

The reason for me to create this issue is that I had a problem with the VMs being created from the example, because on my local Mac I did not have vboxnet1 created as a hostonly network interface. With the current implementation, I got half created VMs which did not recover in a second apply after manually creating the hostonly interface. I had to manually remove the VMs in Virtualbox before I could retry.

Image not cached after downloaded

Terraform config:

resource "virtualbox_vm" "squid" {
  count     = 1
  name      = "squid"
  image     = "https://vagrantcloud.com/geerlingguy/boxes/centos7/versions/1.2.16/providers/virtualbox.box"
  cpus      = 1
  memory    = "256 mib"

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

Run first time:

time terraform apply -auto-approve
real 4m35,572s
user 0m14,910s
sys 0m16,285s


Destroy VM:
`terraform destroy`

Run second time:

time terraform apply -auto-approve
real 4m28,781s
user 0m10,654s
sys 0m15,988s


Download image

time wget https://vagrantcloud.com/geerlingguy/boxes/centos7/versions/1.2.16/providers/virtualbox.box
real 3m27,139s
user 0m3,580s
sys 0m8,700s

Use Image OR Url

Currently, the documentation says the following:

image, string, required: The place of the image file(archive or vagrant box).
url, string, optional, default not set: The url for downloaded vagrant box from external resource (ex. Ubuntu Vagrant box) . If not set using image variable.

My assumption from looking at this documentation is that if I don't specify image (i.e. I don't have the image locally), I can specify Url and it should go pull this from me. I attempt this and get the following:

"image": required field is not set

So I assume maybe it just wants the name of the box as well as the URL, which is fine. But I run this agin with the image name that I want to use (minimal/centos7). But again, I receive another error

open minimal/centos7: no such file or directory

So are my assumptions wrong? Will this provider only work with local copies of an image?

For reference, this is my config:

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

  image  = ""
  url    = "https://app.vagrantup.com/minimal/boxes/centos7"
  cpus   = 2
  memory = "1024mb"
  status = "running"

  network_adapter {
    type = "nat"
  }

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

Issues running terraform v0.12.6 init on ubuntu

Hi, I have downloaded the latest plugin binary from https://github.com/terra-farm/terraform-provider-virtualbox/releases/download/v0.2.0/terraform-provider-virtualbox-v0.2.0-linux_amd64 and placed it in ~/.terraform.d/plugins/linux_amd64 and created a sample main.tf as explained in https://blog.opennix.ru/posts/use_terraform_with_virtualbox/

Unfortunately when I ran 'terraform init' in the folder, I got the below error: -

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...

Provider "virtualbox" not available for installation.

A provider named "virtualbox" could not be found in the Terraform Registry.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
    terraform.d/plugins/linux_amd64

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".


Error: no provider exists with the given name

Can anyone suggest a way how to make this work?
Thanks

[ERROR] Clone *.vdi and *.vmdk to VM folder: exit status 1

Host Linux Mint 19
Terraform v0.11.8
terraform-provider-virtualbox: v.0.1.2
Virtualbox 5.2.18 r124319

resource "virtualbox_vm" "node" {

  name = "${format("node-%02d", count.index+1)}"

  image = "./virtualbox.box"
  url = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
  cpus = 2
  memory = "2GB"

  network_adapter {
    type = "nat"
  }
}
2018/09/06 11:35:22 [INFO] Terraform version: 0.11.8  7a5c1d221ac209bbac66947c369815cd9ca70ed5
2018/09/06 11:35:22 [INFO] Go runtime version: go1.10.1
2018/09/06 11:35:22 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply", "-input=false", "tfplan"}
2018/09/06 11:35:22 [DEBUG] Attempting to open CLI config file: /home/bruno/.terraformrc
2018/09/06 11:35:22 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/09/06 11:35:22 [INFO] CLI command args: []string{"apply", "-input=false", "tfplan"}
2018/09/06 11:35:22 [INFO] command: initializing local backend from plan (not set)
2018/09/06 11:35:22 [DEBUG] checking for provider in "."
2018/09/06 11:35:22 [DEBUG] checking for provider in "/usr/local/bin"
2018/09/06 11:35:22 [DEBUG] checking for provider in ".terraform/plugins/linux_amd64"
2018/09/06 11:35:22 [DEBUG] checking for provider in "/home/bruno/.terraform.d/plugins"
2018/09/06 11:35:22 [DEBUG] checking for provider in "/home/bruno/.terraform.d/plugins/linux_amd64"
2018/09/06 11:35:22 [WARN] found legacy provider "terraform-provider-virtualbox"
2018/09/06 11:35:22 [DEBUG] found valid plugin: "virtualbox", "0.0.0", "/home/bruno/.terraform.d/plugins/linux_amd64/terraform-provider-virtualbox"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "."
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/usr/local/bin"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in ".terraform/plugins/linux_amd64"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/home/bruno/.terraform.d/plugins"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/home/bruno/.terraform.d/plugins/linux_amd64"
2018/09/06 11:35:22 [INFO] command: backend initialized: *local.Local
2018/09/06 11:35:22 [DEBUG] checking for provider in "."
2018/09/06 11:35:22 [DEBUG] checking for provider in "/usr/local/bin"
2018/09/06 11:35:22 [DEBUG] checking for provider in ".terraform/plugins/linux_amd64"
2018/09/06 11:35:22 [DEBUG] checking for provider in "/home/bruno/.terraform.d/plugins"
2018/09/06 11:35:22 [DEBUG] checking for provider in "/home/bruno/.terraform.d/plugins/linux_amd64"
2018/09/06 11:35:22 [WARN] found legacy provider "terraform-provider-virtualbox"
2018/09/06 11:35:22 [DEBUG] found valid plugin: "virtualbox", "0.0.0", "/home/bruno/.terraform.d/plugins/linux_amd64/terraform-provider-virtualbox"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "."
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/usr/local/bin"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in ".terraform/plugins/linux_amd64"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/home/bruno/.terraform.d/plugins"
2018/09/06 11:35:22 [DEBUG] checking for provisioner in "/home/bruno/.terraform.d/plugins/linux_amd64"
2018/09/06 11:35:22 [INFO] backend/local: starting Apply operation
2018/09/06 11:35:22 [INFO] terraform: building graph: GraphTypeApply
emoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "image":*terraform.ResourceAttrDiff{Old:"", New:"./virtualbox.box", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "url":*terraform.ResourceAttrDiff{Old:"", New:"https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "network_adapter.0.ipv4_address_available":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
2018/09/06 11:35:22 [DEBUG] Resource state not found for "virtualbox_vm.node": virtualbox_vm.node
2018/09/06 11:35:22 [DEBUG] resource virtualbox_vm.node using provider provider.virtualbox
2018/09/06 11:35:22 [DEBUG] ReferenceTransformer: "virtualbox_vm.node" references: []
2018/09/06 11:35:22 [DEBUG] ReferenceTransformer: "provider.virtualbox" references: []
2018/09/06 11:35:22 [DEBUG] Starting graph walk: walkApply
2018-09-06T11:35:22.664-0300 [DEBUG] plugin: starting plugin: path=/home/bruno/.terraform.d/plugins/linux_amd64/terraform-provider-virtualbox args=[/home/bruno/.terraform.d/plugins/linux_amd64/terraform-provider-virtualbox]
2018-09-06T11:35:22.665-0300 [DEBUG] plugin: waiting for RPC address: path=/home/bruno/.terraform.d/plugins/linux_amd64/terraform-provider-virtualbox
2018-09-06T11:35:22.672-0300 [DEBUG] plugin.terraform-provider-virtualbox: plugin address: timestamp=2018-09-06T11:35:22.672-0300 address=/tmp/plugin658649940 network=unix
virtualbox_vm.node: Creating...
  cpus:                                     "" => "2"
  image:                                    "" => "./virtualbox.box"
  memory:                                   "" => "2GB"
  name:                                     "" => "node-01"
  network_adapter.#:                        "" => "1"
  network_adapter.0.device:                 "" => "IntelPro1000MTServer"
  network_adapter.0.ipv4_address:           "" => "<computed>"
  network_adapter.0.ipv4_address_available: "" => "<computed>"
  network_adapter.0.mac_address:            "" => "<computed>"
  network_adapter.0.status:                 "" => "<computed>"
  network_adapter.0.type:                   "" => "nat"
  status:                                   "" => "running"
  url:                                      "" => "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
2018-09-06T11:35:23.751-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-vbm.go:60: executing: VBoxManage list vms
2018-09-06T11:35:23.819-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-vbm.go:45: executing: VBoxManage createvm --name node-01 --register --basefolder /home/bruno/.terraform/virtualbox/machine
2018-09-06T11:35:23.917-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-vbm.go:75: executing: VBoxManage showvminfo node-01 --machinereadable
2018-09-06T11:35:24.005-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-vbm.go:45: executing: VBoxManage clonehd /home/bruno/.terraform/virtualbox/gold/virtualbox/ubuntu-bionic-18.04-cloudimg-configdrive.vmdk /home/bruno/.terraform/virtualbox/machine/node-01/ubuntu-bionic-18.04-cloudimg-configdrive.vmdk
2018-09-06T11:35:24.078-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-vbm.go:45: executing: VBoxManage clonehd /home/bruno/.terraform/virtualbox/gold/virtualbox/ubuntu-bionic-18.04-cloudimg.vmdk /home/bruno/.terraform/virtualbox/machine/node-01/ubuntu-bionic-18.04-cloudimg.vmdk
2018-09-06T11:35:24.149-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-resource_vm.go:247: [ERROR] Clone *.vdi and *.vmdk to VM folder: exit status 1
2018/09/06 11:35:24 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* virtualbox_vm.node: exit status 1
2018/09/06 11:35:24 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* virtualbox_vm.node: exit status 1
2018/09/06 11:35:24 [TRACE] [walkApply] Exiting eval tree: virtualbox_vm.node
2018/09/06 11:35:24 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2018/09/06 11:35:24 [TRACE] dag/walk: upstream errored, not walking "provider.virtualbox (close)"
2018/09/06 11:35:24 [TRACE] dag/walk: upstream errored, not walking "root"

Error: Error applying plan:

1 error(s) occurred:

* virtualbox_vm.node: 1 error(s) occurred:

* virtualbox_vm.node: exit status 1

Terraform does not automatically rollback in the face of errors.
2018/09/06 11:35:24 [DEBUG] plugin: waiting for all plugin processes to complete...
Instead, your Terraform state file has been partially updated with
2018-09-06T11:35:24.158-0300 [DEBUG] plugin.terraform-provider-virtualbox: pid-25036-rpc_server.go:48: [ERR] plugin: plugin server: accept unix /tmp/plugin658649940: use of closed network connection
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.