diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index f39175a..07f1ca1 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -134,6 +134,20 @@ module Vagrant ip += '/24' end + if ! bridge_exists?(bridge_name) + if not bridge_ip + raise "Bridge is missing and no IP was specified!" + end + + @logger.info "Creating the bridge #{bridge_name}" + cmd = [ + 'brctl', + 'addbr', + bridge_name + ] + @sudo_wrapper.run(*cmd) + end + if ! bridge_has_an_ip?(bridge_name) if not bridge_ip raise "Bridge has no IP and none was specified!" @@ -148,6 +162,7 @@ module Vagrant bridge_name ] @sudo_wrapper.run(*cmd) + @sudo_wrapper.run('ifconfig', bridge_name, 'up') end cmd = [ diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index e9e6fd5..18a8894 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -106,8 +106,8 @@ Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/ Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z} # - Private network script and commands Whitelist.add '<%= cmd_paths['ip'] %>', 'addr', 'add', /(\d+|\.)+\/24/, 'dev', /.+/ -Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, 'down' -Whitelist.add '<%= cmd_paths['brctl'] %>', 'delbr', /.+/ +Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, /(up|down)/ +Whitelist.add '<%= cmd_paths['brctl'] %>', /(addbr|delbr)/, /.+/ Whitelist.add_regex %r{<%= pipework_regex %>}, '**' ##