chef-lctp/site-cookbooks/lctp-network/recipes/default.rb

42 lines
789 B
Ruby

include_recipe "network_interfaces"
package "ifmetric"
cookbook_file "/etc/network/interfaces" do
source "interfaces"
mode 0644
owner "root"
group "root"
end
network = node.lctp_network
unless network.domain_servers.empty? and network.search_domains.empty?
template "/etc/resolvconf/resolv.conf.d/head" do
source "resolv.conf.erb"
variables(network: network)
end
end
network.interfaces.each do |device, iface|
network_interfaces device do
if iface.attribute? "metric"
metric iface.metric
end
if iface.attribute? "static_ip"
target iface.static_ip
if iface.attribute? "netmask"
mask iface.netmask
else
mask "255.255.255.0"
end
bootproto "static"
else
bootproto "dhcp"
end
end
end