def generate_config
b = binding
case node[:platform]
when "centos","redhat","fedora"
content = %{
<% if @new_resource.device %>DEVICE=<%= @new_resource.device %><% end %>
<% if @new_resource.onboot %>ONBOOT=<%= @new_resource.onboot %><% end %>
<% if @new_resource.bootproto %>BOOTPROTO=<%= @new_resource.bootproto %><% end %>
<% if @new_resource.target %>IPADDR=<%= @new_resource.target %><% end %>
<% if @new_resource.mask %>NETMASK=<%= @new_resource.mask %><% end %>
<% if @new_resource.network %>NETWORK=<%= @new_resource.network %><% end %>
<% if @new_resource.bcast %>BROADCAST=<%= @new_resource.bcast %><% end %>
<% if @new_resource.onparent %>ONPARENT=<%= @new_resource.onparent %><% end %>
}
template = ::ERB.new(content)
network_file_name = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
converge_by ("generate configuration file : #{network_file_name}") do
network_file = ::File.new(network_file_name, "w")
network_file.puts(template.result(b))
network_file.close
end
Chef::Log.info("#{@new_resource} created configuration file")
when "debian","ubuntu"
when "slackware"
end
end