terra-farm / terraform-provider-virtualbox

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

exit status 1 - hostonly network #24

Closed tylerauerbeck closed 5 years ago

tylerauerbeck commented 6 years ago

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.

tylerauerbeck commented 6 years ago

Going to close this one as I see that only nat and bridged are supported. The README.md is a bit misleading because it states the following:

.#.type, string, requried: The type of the network, allowed values: 'nat', 'bridged', 'hostonly', 'internal', 'generic'.

Would it make sense to update this?

pyToshka commented 6 years ago

@tylerauerbeck , You setup wrong network interface. host_interface its name of virtual box adapter usually this name eq vboxnet0. In Your example you use workstation interface.

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
    memory = "512 mib",
   // user_data = "${file("user_data")}"

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

}
VoyTechnology commented 5 years ago

@tylerauerbeck, this issue is pretty old. I will close, but feel free to re-open if you are still having problems.