Skip to content

Instantly share code, notes, and snippets.

@spheromak
Created January 7, 2010 04:33
Show Gist options
  • Save spheromak/270991 to your computer and use it in GitHub Desktop.
Save spheromak/270991 to your computer and use it in GitHub Desktop.
route first pass
def generate_config
conf = Hash.new
case node[:platform]
when ("centos" || "redhat" || "fedora")
# walk the collection
@collection.each do |resource|
if resource.is_a? Chef::Resource::Route
# default to eth0
if resource.device
dev = resource.device
else
dev = "eth0"
end
if resource.action? :add
conf[dev] << "#{resource.name} via #{resource.gateway}"
puts resource
puts resource.action
end
end
conf.each do |dev|
network_file = ::File.new("/etc/sysconfig/network-scripts/route.#{dev}", "w")
network_file.puts(conf[dev])
network_file.close
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment