Added support for static routes on CentOS and Fedora.

This commit is contained in:
Timo Mkinen 2012-02-06 16:03:44 +02:00
parent 5d8ea214ea
commit 946d5691c1
2 changed files with 25 additions and 2 deletions

View file

@ -230,10 +230,13 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
# $device: # $device:
# Interface to use for this route. # Interface to use for this route.
# #
define network::route($gateway, $device, $ipv6gateway = "") { define network::route($gateway = "NONE", $device, $ipv6gateway = "") {
case $name { case $name {
"default": { "default": {
if "${gateway}" == "NONE" {
fail("Cannot set empty gateway for default route.")
}
case $operatingsystem { case $operatingsystem {
centos,fedora: { centos,fedora: {
include network::helper::restart include network::helper::restart
@ -280,7 +283,24 @@ define network::route($gateway, $device, $ipv6gateway = "") {
} }
} }
} }
default: { fail("Only default routes are currently supported") } default: {
case $operatingsystem {
"fedora","centos": {
include network::helper::restart
file { "/etc/sysconfig/network-scripts/route-${device}":
ensure => present,
content => template("network/route-if.erb"),
mode => 0644,
owner => "root",
group => "root",
notify => Exec["restart-network"],
}
}
default: {
fail("Custom routes not supported in ${operatingsystem}")
}
}
}
} }
} }

View file

@ -0,0 +1,3 @@
ADDRESS0=<%= name.split('/')[0] %>
NETMASK0=<%= name.split('/')[1] %>
<% if gateway != "NONE" %>GATEWAY0=<%= gateway %><% end %>