terra-farm / terraform-provider-virtualbox

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

Nat network support #82

Closed isage closed 3 years ago

isage commented 4 years ago

Add support for virtualbox nat networks as a resource and natnetwork type for NICs E.g.:

resource "virtualbox_natnetwork" "vmnet10" {
    name = "vmnet10"
    dhcp = true
    network = "192.168.6.0/24"
}

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

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

  network_adapter {
    type           = "natnetwork"
    nat_network    = virtualbox_natnetwork.vmnet10.name
  }
}

Requires https://github.com/terra-farm/go-virtualbox/pull/13

VoyTechnology commented 4 years ago

Please take a look at the failing CI @isage.

isage commented 4 years ago

It states right there in description that it requires terra-farm/go-virtualbox#13 of course it will fail otherwise.

VoyTechnology commented 4 years ago

Sorry, I missed that.

nevill commented 4 years ago

I just compiled the code (of course with terra-farm/go-virtualbox#13) and everything works well.

The thing is, in NAT Network, we cannot connect to the VM directly. But, usually terraform provisioners require a network connection to control it. Is there any work-around? Like providing a port forward resource and using it as connection?

isage commented 4 years ago

I'm not sure of usage cases (i was contracted to implement nat network support), but yeah, nat network supports port forwarding, so it should be doable ( in separate pull request)

On Sun, 3 Nov 2019, 18:17 Nevill, notifications@github.com wrote:

I just compiled the code (of course with terra-farm/go-virtualbox#13 https://github.com/terra-farm/go-virtualbox/pull/13) and everything works well.

The thing is, in NAT Network, we cannot connect to the VM directly. But, usually terraform provisioners require a network connection to control it. Is there any work-around? Like providing a port forward resource and using it as connection?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terra-farm/terraform-provider-virtualbox/pull/82?email_source=notifications&email_token=AACC2IIYDYTO5JJOKRAI6HLQR3TQXA5CNFSM4JESDEQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5VCHY#issuecomment-549146911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACC2IM66K7MHDGMFN6D5NTQR3TQXANCNFSM4JESDEQA .

patsevanton commented 4 years ago

I think need use NAT Network with Host-only Network.

nevill commented 4 years ago

I think need use NAT Network with Host-only Network.

@patsevanton In this case, Host-only + NAT is working and preferred. Because it doesn't need to create a NAT Network.

patsevanton commented 4 years ago

@nevill NAT interface have equal IP address on all virtualbox machine

https://github.com/terra-farm/terraform-provider-virtualbox/issues/75

Host-only + NAT Network have different IP address on all virtualbox machine

nevill commented 4 years ago

@nevill NAT interface have equal IP address on all virtualbox machine

75

Host-only + NAT Network have different IP address on all virtualbox machine

Yes, I understand the difference. Host-only NIC can have different IPs. In this way, they're equivalent, but NAT Network has one more resource to create.

I'd like to use NAT Network if the connection problem mentioned above gets resolved.

patsevanton commented 3 years ago

Hello! may be merge PR?

jpts commented 3 years ago

Hi folks, I'm interested in getting this functionality merged in (in addition to the go library PR). Is there anything else that needs to be done for this, except for rebasing and resolving conflicts?

@isage are you still interested in picking this up, or should I create a new PR to pickup the work in?

isage commented 3 years ago

I'm not interested, so go ahead. Same goes for go-virtualbox.

On Mon, May 10, 2021, 01:48 jpts @.***> wrote:

Hi folks, I'm interested in getting this functionality merged in (in addition to the go library PR http:///terra-farm/go-virtualbox/pull/13). Is there anything else that needs to be done for this, except for rebasing and resolving conflicts?

@isage https://github.com/isage are you still interested in picking this up, or should I create a new PR to pickup the work in?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terra-farm/terraform-provider-virtualbox/pull/82#issuecomment-835918292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACC2IJHZEPRJHT2DSH6O3DTM4GKZANCNFSM4JESDEQA .

VoyTechnology commented 3 years ago

Closing in favour of #103.