Last active
December 28, 2015 23:29
-
-
Save holysugar/7579066 to your computer and use it in GitHub Desktop.
Ubuntu を Vagrant の :public_network で試す時に default route を public_network 側などに設定する chef のコード(やっつけ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
route del default | |
route add default gw <%= @gateway %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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