-
Notifications
You must be signed in to change notification settings - Fork 181
network.ipv4 does not work for debian squeeze #106
Comments
@paneq that is pretty weird, I'll try to reproduce it on a VBox VM and will get back to you. tks for reporting |
Here is my workaround that I put into require 'vagrant-lxc/provider'
require 'vagrant-lxc/action'
module Vagrant
module LXC
class Provider
def ssh_info
# If the Container is not created then we cannot possibly SSH into it, so
# we return nil.
return nil if state == :not_created
ip = @machine.config.vm.networks.map do |type, options|
type == :private_network && options[:ip] || nil
end.compact.first || @driver.assigned_ip
{
:host => ip,
:port => @machine.config.ssh.guest_port
}
end
end
module Action
class << self
alias_method :original_action_boot, :action_boot
def action_boot
action_builder = original_action_boot
action_builder.insert_before(Vagrant::LXC::Action::Boot, Vagrant::Action::Builder.new.tap{|b| b.use Vagrant::LXC::Action::Magic } )
action_builder
end
end
class Magic
def initialize(app, env)
@app = app
end
def call(env)
@env = env
env[:machine].config.vm.networks.each do |type, options|
next unless type == :private_network && options[:ip]
try ||= 0
try += 1
inter = Pathname.new(@env[:machine].provider.driver.rootfs_path).join("etc/network/interfaces")
begin
inter.open("w") do |f|
f << <<-INTER_CONTENT
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address #{options.fetch(:ip)}
netmask 255.255.255.0
gateway 0.0.0.0
INTER_CONTENT
end
rescue Errno::EACCES
puts "Need to use sudo to configure network interface"
command = "sudo chmod 666 #{inter}"
puts command
`#{command}`
redo if try == 1
end
break
end
@app.call env
end
end
end
end
end |
Tks Robert! Fábio Rehm
|
Seems to be also needed for Debian 7 (wheezy) as it always starts dhcp no matter what network configuration I set in my Vagrantfile. |
Closing in favor of #120 |
This is related to #31 which however is a very big ticket so I wanted to create a smaller one. Feel free to close it if you already know about this.
Host is Ubuntu 12.04.
The text was updated successfully, but these errors were encountered: