Skip to content

Instantly share code, notes, and snippets.

@kumaxim
Last active May 9, 2018 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kumaxim/5277f9ac1ab4312b6ec5 to your computer and use it in GitHub Desktop.
Save kumaxim/5277f9ac1ab4312b6ec5 to your computer and use it in GitHub Desktop.
Vagrantfile with ubuntu/trusty32 to solve problem cloud-init-nonet timeout
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box.
config.vm.box = "ubuntu/trusty32"
# Disable automatic box update checking.
config.vm.box_check_update = false
# Create a private network, which allows host-only access to the machine
# using a specific IP.
### NOTE: remember ip address. It need also below
### NOTE: auto_config need be set in false.
config.vm.network "private_network", ip: "192.168.35.25", auto_config: false
# Boot timeout, in sec
config.vm.boot_timeout = 1200
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
### Change network card to PCnet-FAST III
# For NAT adapter
vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"]
# For host-only adapter
vb.customize ["modifyvm", :id, "--nictype2", "Am79C973"]
end
# Enable provisioning with a shell script.
config.vm.provision "shell", inline: <<-SHELL
### Create configuration for host-only adapter. In my case eth1
# Clear previous setting
rm -f /etc/network/interfaces.d/eth1.cfg
# Create new setting
echo "auto eth1" >> /etc/network/interfaces.d/eth1.cfg
echo "iface eth1 inet static" >> /etc/network/interfaces.d/eth1.cfg
# ip address should be the same as in a private_network
echo "address 192.168.35.25" >> /etc/network/interfaces.d/eth1.cfg
echo "netmask 255.255.255.0" >> /etc/network/interfaces.d/eth1.cfg
# Restart adapter for apply new setting
ifdown eth1 && ifup eth1
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment