Skip to content

Instantly share code, notes, and snippets.

@tily
Created October 29, 2014 01:49
Show Gist options
  • Save tily/67829898fe16ebb17541 to your computer and use it in GitHub Desktop.
Save tily/67829898fe16ebb17541 to your computer and use it in GitHub Desktop.
DHCP で振られた IP を元にプライベート IP を振る chef-apply レシピ
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