Skip to content

Instantly share code, notes, and snippets.

@holysugar
Last active December 28, 2015 23:29
Show Gist options
  • Save holysugar/7579066 to your computer and use it in GitHub Desktop.
Save holysugar/7579066 to your computer and use it in GitHub Desktop.
Ubuntu を Vagrant の :public_network で試す時に default route を public_network 側などに設定する chef のコード(やっつけ
#!/bin/sh
route del default
route add default gw <%= @gateway %>
if node['route']['gateway']
execute "networking-restart" do
command "service networking restart"
action :nothing
end
template "/etc/network/if-up.d/route" do
source "route.erb"
mode 0755
owner "root"
group "root"
variables({ gateway: node['route']['gateway'] })
notifies :run, "execute[networking-restart]"
end
end
agrant.configure("2") do |config|
# ... 省略されています
config.vm.network :public_network, ip: "192.168.1.10", bridge: "en0: Ethernet"
config.vm.provision :chef_solo do |chef|
chef.json = {
:route => {
:gateway => '192.168.1.1'
}
}
}
# ... 省略されています
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment