Additional interface when assigning a private address in Vagrantile

76 megtekintés
Ugrás az első olvasatlan üzenetre

BRIT

olvasatlan,
2016. máj. 26. 23:36:192016. 05. 26.
– Vagrant
Hi all,
I'm running VirtualBox (5.0.20) under Windows 10 and have a quick question about creating a package box from VirtualBox guest.

  1. My Ubuntu 14.04.4 guest I configure with a single NIC (attached to NAT) and then I go through and install the OS, VirtualBox Guest Additions etc etc. to get it to a good point that I will use as a base package.  We'll assume that I've called my VirtualBox guest "UbuntuBasePackage".
  2. I create a folder C:\Vagrant\Boxes and through a command prompt, enter that folder
  3. I create a text file (UbuntuBasePackage.txt) that will be used as the initial provisioning (I hope that's the correct term) Vagrantfile for the package. The text file contains a custom SSH username ("bob") and password that I'll use within my boxes. It looks like this:
  4. # -*- mode: ruby -*-
    # vi: set ft=ruby :
     
    Vagrant.configure(2) do |config|
      config.vm.box = "file://D://Vagrant//Boxes//UBP.box"
      config.vm.define "UBP"
      config.vm.provider "virtualbox" do |v|
        v.name = "UBP"
           v.memory = 1024
           v.cpus = 1
      end
      config.ssh.username = "bob"
      config.ssh.password = "bobbob"
    end

  5. I then create my base package using the following command
    1. vagrant package --base UbuntuBasePackage --output UBP.box --vagrantfile UBP.txt
  6. All goes great.
  7. Now I create C:\Vagrant\UBP and through a command prompt, enter that folder
  8. I now initialize my new box with the following
    1. vagrant init C:\Vagrant\Boxes\UBP.box
  9. All goes great and a Vagrantfile appears in the UBP folder.
  10. It's at this point that developers would potentially customize the box to their own environments, so my instructions are to edit the new Vagrantfile to look something like this
  11. # -*- mode: ruby -*-
    # vi: set ft=ruby :
    Vagrant.configure(2) do |config|
      config.vm.box = "C:/Vagrant/Boxes/UBP.box"
      config.vm.network "private_network", ip: "192.168.56.40"
      config.vm.define "UBP" 
      config.vm.provider "virtualbox" do |v| 
        v.name = "UBP" 
        v.memory = 1024 
      end 
    end
  12. Please note the configuration of the additional private_network interface!
  13. Once the file is saved, we start the guest up with the normal vagrant up.
    1. I notice that the log shows that Adapter 1: nat and Adapter 2: hostonly
  14. All is just fine, but I've noticed that there are some interesting results when it comes to the networking.  
    1. I can (from the host) SSH into the 192.168.56.40 address - great!
    2. I can (from the host) access a WWW server from 192.168.56.40 - great!
    3. From the guest, I run ifconfig and notice that my eth1 (2nd "HostOnly" NIC) is configured with a DHCP address of 192.168.56.101
    4. I can (from the host) now access both SSH and WWW from 192.168.56.101
  15. I check the /etc/network/interfaces file and sure enough, there's a couple of additional entries
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet static
      address 192.168.56.40
      netmask 255.255.255.0
#VAGRANT-END
                                        I check the original UbuntuBasePackage server within VirtualBox, and there's the loopback and eth0 assigned as I expect. I can understand the Vagrant begin being added to the file and indeed, that's the IP address that was set in the Vagrantfile, but where's the initial request for DHCP coming from (in bold)? 

                                        Alvaro Miranda Aguilera

                                        olvasatlan,
                                        2016. máj. 26. 23:52:252016. 05. 26.
                                        – vagra...@googlegroups.com
                                        Hello,

                                        Can you check if the same happen with this box?

                                        cbednarski/ubuntu-1404


                                        You can create a new Vagrantfile and add the networking part.
                                        Or you can update the current one and do vagrant destroy ; vagrant up

                                        Thanks
                                        Alvaro.


                                        --
                                        This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
                                         
                                        GitHub Issues: https://github.com/mitchellh/vagrant/issues
                                        IRC: #vagrant on Freenode
                                        ---
                                        You received this message because you are subscribed to the Google Groups "Vagrant" group.
                                        To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
                                        To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/63f06ed4-4c13-42db-a91e-573007e66eb1%40googlegroups.com.
                                        For more options, visit https://groups.google.com/d/optout.

                                        BRIT

                                        olvasatlan,
                                        2016. máj. 30. 15:58:552016. 05. 30.
                                        – Vagrant
                                        So perhaps this is something wrong with my (recently built) Ubuntu system, but I can't add *any* public or private boxes from hashicorp.

                                        cd ~/vagrant
                                        mkdir ama
                                        cd ama
                                        vagrant init cbednarski/
                                        ubuntu-1404
                                        vagrant up
                                        [ error message : vm:
                                        * The box 'cbednarski/ubuntu-1404' could not be found.
                                        ]
                                        vagrant box add
                                        cbednarski/ubuntu-1404 https://atlas.hashicorp.com/cbednarski/boxes/ubuntu-1404
                                        [ error message : 
                                        The box failed to unpackage properly. Please verify that the box
                                        file you're trying to add is not corrupted and try again. The
                                        output from attempting to unpackage (if any):

                                        bsdtar: Error opening archive: Unrecognized archive format]


                                        I'm obviously doing something very wrong here. This is the first time that I've attempted to use vagrant with Ubuntu, so is there something additional that I need to do??

                                        Alvaro Miranda Aguilera

                                        olvasatlan,
                                        2016. máj. 30. 17:20:232016. 05. 30.
                                        – vagra...@googlegroups.com
                                        Hello,

                                        Are you behind any firewall or proxy that may be stopping this to work?
                                        Or do you need to define a proxy?

                                        Please try this:

                                        curl -L https://atlas.hashicorp.com/cbednarski/ubuntu-1404.json

                                        If that works, then I would suggest reinstall vagrant on that machine.

                                        If after reinstall the issue remians then try this:

                                        for cmd.exe
                                        set VAGRANT_LOG=debug

                                        for bash
                                        export VAGRANT_LOG=debug

                                        then:

                                        vagrant up

                                        And share the generated text over a gist. (gist.github.com)

                                        Thanks
                                        Alvaro.

                                        --
                                        This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
                                         
                                        GitHub Issues: https://github.com/mitchellh/vagrant/issues
                                        IRC: #vagrant on Freenode
                                        ---
                                        You received this message because you are subscribed to the Google Groups "Vagrant" group.
                                        To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

                                        BRIT

                                        olvasatlan,
                                        2016. máj. 30. 18:07:282016. 05. 30.
                                        – Vagrant
                                        the "curl -L ..." worked just fine.  Oddly enough, I went through and reinstalled both vagrant and virtualbox before reading your post Alvaro.

                                        One thing I do notice, working on my Ubuntu desktop: there are two ways of loading VirtualBox, with differing results:
                                        1. Dash > Applications > VirtualBox - this loads up, what I would imagine to be, the "System" level version of VirtualBox, which has about 6 VMs listed at the moment
                                        2. Terminal > virtualbox - this loads up, I think, my "user" version of VirtualBox, which has just one VM ("t1"). I also notice that the terminal remains current until the GUI shuts down.
                                        When in a terminal, I run "vboxmanage list vms" I see just my one VM ("t1"). For the time being, I'll stick to that.

                                        However, running any one of the following results in an error:
                                        The error itself : 
                                        The box failed to unpackage properly. Please verify that the box
                                        file you're trying to add is not corrupted and try again. The
                                        output from attempting to unpackage (if any):

                                        bsdtar: Error opening archive: Unrecognized archive format

                                        (BTW, curl -L ... still works just flawlessly.  Reading through it, I see that the 0.3.0 version notes the files to be located at https://atlas.hashicorp.com/cbednarski/boxes/ubuntu-1404/versions/0.3.0/providers/virtualbox.box, so when I run
                                        I do get to download the box!  So, I'm getting closer...

                                        Alvaro Miranda Aguilera

                                        olvasatlan,
                                        2016. máj. 30. 18:11:512016. 05. 30.
                                        – vagra...@googlegroups.com

                                        On Tue, May 31, 2016 at 10:07 AM, BRIT <buildingrelia...@gmail.com> wrote:
                                        for cmd.exe
                                        set VAGRANT_LOG=debug

                                        for bash
                                        export VAGRANT_LOG=debug

                                        then:

                                        vagrant up

                                        And share the generated text over a gist. (gist.github.com)

                                        Hello, are you installing Vagrant from vagrantup.com ?

                                        Can you share:
                                        vagrant version
                                        vagrant plugin list

                                        Also,Can you do the debug part ?
                                        Check my previous email but basically is

                                        in bash
                                        export VAGRANT_LOG=debug
                                        vagrant up 2>&1 | tee vagrant_up.log

                                        Thanks
                                        Alvaro.

                                        BRIT

                                        olvasatlan,
                                        2016. máj. 30. 19:00:492016. 05. 30.
                                        – Vagrant
                                        • vagrant version 1.8.1
                                        • vagrant-share (1.1.5, system)
                                        Log file is attached.  Editing the file with the private network worked just fine.  This hasn't been the issue.  The issue is that when I create a base box, there's an additional NIC that's obtaining DHCP settings from somewhere...
                                        vagrant_up.log.tar.gz

                                        Alvaro Miranda Aguilera

                                        olvasatlan,
                                        2016. máj. 31. 12:16:432016. 05. 31.
                                        – vagra...@googlegroups.com
                                        Hello, on vagrant up, vagrant will clear the networking of the box and set whats on the Vagrantfile.

                                        seems i miss understood the issue, sorry.

                                        IF you still have the base box, can you share a `ifconfig -a` as root ?

                                        --
                                        This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
                                         
                                        GitHub Issues: https://github.com/mitchellh/vagrant/issues
                                        IRC: #vagrant on Freenode
                                        ---
                                        You received this message because you are subscribed to the Google Groups "Vagrant" group.
                                        To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

                                        BRIT

                                        olvasatlan,
                                        2016. jún. 1. 21:13:162016. 06. 01.
                                        – Vagrant
                                        I found the issue. It's technically my issue, but a little misleading and I believe it to be more of a VirtualBox "gotcha" than anything else.

                                        So - to re-iterate - building the base box in VirtualBox, I start off with a single (NAT) interface, to build the OS etc. Once the OS is installed, I then add a HostOnly NIC so that I can ssh in to run a number of scripts to install software etc etc. The idea was then to remove the HostOnly NIC before packaging up the base box before it gets "vagrant box add(ed)" to the dev's systems (where they can put their own HostOnly NICs, configured to their liking).

                                        Before I package the box up, I simply unchecked the Enable Network Adapter for the HostOnly NIC in VirtualBox. That's not enough.  I have to set the Attached to: to Not attached too. 

                                        Maybe it's just me, but I've done this time and time again and it's solved my issue...!!!

                                        Thanks for all your assistance though Alvaro

                                        BRIT

                                        olvasatlan,
                                        2016. jún. 1. 21:17:262016. 06. 01.
                                        – Vagrant
                                        Actually, that's NOT the case - networking is one section in vagrant where it builds up from the base package, then subsequent Vagrantfile's, appending to the configuration, not overriding. From : https://www.vagrantup.com/docs/vagrantfile/
                                        However, for things such as defining networks, the networks are actually appended to each other
                                        Válasz mindenkinek
                                        Válasz a szerzőnek
                                        Továbbítás
                                        0 új üzenet