0

I modified the Vagrantfile for taiga-vagrant based on VAGRANT DOCS/Public Networks as follows:

# -*- mode: ruby -*-
# vi: set ft=ruby :
require "./source.rb"

ROOT_PATH = File.dirname(__FILE__)

VAGRANTFILE_API_VERSION = "2"

def configure_extra(config)
end

def configure(config)
  config.vm.box = "trusty64"
  config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Host name
  config.vm.hostname = "taiga"

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine.
  config.vm.network :forwarded_port, host: 8000, guest: 8000
  config.vm.network :forwarded_port, host: 9001, guest: 9001

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  config.vm.network "public_network", autoconfig: false

  config.vm.provision "fix-no-tty", type: "shell" do |s|
        s.privileged = false
        s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
  end

  # manual ip
  config.vm.provision "shell",
    run: "always",
    inline: "ifconfig eth1 xxx.yyy.zzz.153 netmask 255.255.255.0 up"

  # manual ipv6
  config.vm.provision "shell",
    run: "always",
    inline: "ifconfig eth1 inet6 add fc00::17/7"

  # default router
  config.vm.provision "shell",
    run: "always",
    inline: "route add default gw xxx.yyy.zzz.132"

  # default router ipv6
  config.vm.provision "shell",
    run: "always",
    inline: "route -A inet6 add default gw fc00::1 eth1"

# delete default gw on eth0
  config.vm.provision "shell",
    run: "always",
    inline: "eval `route -n | awk '{ if ($8 ==\"eth0\" && $2 != \"0.0.0.0\") print \"route del default gw \" $2; }'`"

  # If true, then any SSH connections made will enable agent forwarding.
  # Default value: false
  config.ssh.forward_agent = true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  config.vm.synced_folder "./data", "/home/vagrant/data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  config.vm.provider "virtualbox" do |vb|
    # Boot with headless mode
    vb.gui = false

    host = RbConfig::CONFIG['host_os']

    # Giving a quarter of system memory to VM and access to all available cpu cores
    if host =~ /darwin/
      cpus = `sysctl -n hw.ncpu`.to_i
      # sysctl returns Bytes, converting to MB...
      mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
    elsif host =~ /linux/
      cpus = `nproc`.to_i
      # meminfo returns KB, converting to MB...
      mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
    else
      # hardcoding values for windows...
      cpus = 2
      mem = 2048
    end

    vb.customize ["modifyvm", :id, "--memory", mem]
    vb.customize ["modifyvm", :id, "--cpus", cpus]
  end

  # Provisioning
  config.vm.provision "shell" do |shell|
    vagrant_shell_scripts_configure(
      shell,
      File.join(ROOT_PATH, "scripts"),
      "provision.sh",
      {}
    )
  end
end

# Look for a Vagrantfile.local to load
local_vagrantfile = "#{__FILE__}.local"
if File.exists?(local_vagrantfile)
  eval File.read(local_vagrantfile)
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  configure config
  configure_extra config
end

After vagrant up, I am asked for "Which interface should the network bridge to?". After selecting 1 (for eth0), the VirtualBox virtual machine launches just fine and I can connect via ssh. The networking interface(s) settings of this VM are:

eth0      Link encap:Ethernet  HWaddr 08:00:27:70:2a:9d  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe70:2a9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1462 errors:0 dropped:0 overruns:0 frame:0
          TX packets:968 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:151879 (151.8 KB)  TX bytes:122611 (122.6 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:2e:e8:7f  
          inet addr:xxx.yyy.zzz.153  Bcast:xxx.yyy.zzz.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe2e:e87f/64 Scope:Link
          inet6 addr: fc00::17/7 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1335 errors:0 dropped:0 overruns:0 frame:0
          TX packets:683 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1078620 (1.0 MB)  TX bytes:85690 (85.6 KB)

Small Update

While launching, there are several messages of

default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    ...

Finally, though, the machine starts. I can access taiga just fine from the outer internet. But, is it necessary to have both of these interfaces? Can I not have the static public IP for eth0 only?

0

The post at https://github.com/mitchellh/vagrant/pull/1745#issuecomment-33159374 was useful. The following line did the trick!

config.vm.network "public_network", :bridge => "eth0", ip: "xxx.yyy.zzz.153", :netmask => "255.255.255.128", auto_config: false
  • Need to gather more info, and try again. Though I am not asked anymore which interface to bridge to, the public IP is set on ethernet 1 and not ethernet 0. – Nikos Alexandris Dec 14 '15 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.