Created
January 7, 2010 04:33
-
-
Save spheromak/270991 to your computer and use it in GitHub Desktop.
route first pass
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
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