Created
October 29, 2014 01:49
-
-
Save tily/67829898fe16ebb17541 to your computer and use it in GitHub Desktop.
DHCP で振られた IP を元にプライベート IP を振る chef-apply レシピ
This file contains 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
addresses = node['network']['interfaces']['eth1']['addresses'] | |
ip, info = addresses.find {|k, v| k.match(/^10\./) } | |
netmask = info['netmask'] | |
file '/etc/sysconfig/network-scripts/ifcfg-eth1' do | |
content <<-EOF | |
DEVICE=eth1 | |
ONBOOT=yes | |
BOOTPROTO=static | |
IPADDR=#{ip} | |
NETMASK=#{netmask} | |
EOF | |
end | |
service 'network' do | |
action :restart | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment