Added support for static routes on CentOS and Fedora.
This commit is contained in:
parent
5d8ea214ea
commit
946d5691c1
2 changed files with 25 additions and 2 deletions
|
@ -230,10 +230,13 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
|
|||
# $device:
|
||||
# Interface to use for this route.
|
||||
#
|
||||
define network::route($gateway, $device, $ipv6gateway = "") {
|
||||
define network::route($gateway = "NONE", $device, $ipv6gateway = "") {
|
||||
|
||||
case $name {
|
||||
"default": {
|
||||
if "${gateway}" == "NONE" {
|
||||
fail("Cannot set empty gateway for default route.")
|
||||
}
|
||||
case $operatingsystem {
|
||||
centos,fedora: {
|
||||
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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
3
network/templates/route-if.erb
Normal file
3
network/templates/route-if.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
ADDRESS0=<%= name.split('/')[0] %>
|
||||
NETMASK0=<%= name.split('/')[1] %>
|
||||
<% if gateway != "NONE" %>GATEWAY0=<%= gateway %><% end %>
|
Loading…
Add table
Reference in a new issue