Added support for RHEL and did some syntax cleaning

Assume that "RedHat" also works where "CentOS" does.
This commit is contained in:
Ossi Salmi 2012-09-05 16:42:02 +03:00
parent e9aae1dcf6
commit 24ecb51f6f
63 changed files with 544 additions and 497 deletions

View file

@ -4,22 +4,22 @@
# This class is automatically included when needed.
#
class network::helper::restart {
case $operatingsystem {
centos,fedora: {
case $::operatingsystem {
"centos","redhat","fedora": {
exec { "restart-network":
command => "/sbin/service network restart",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
refreshonly => true,
}
}
openbsd: {
"openbsd": {
exec { "restart-network":
command => "/sbin/route delete default ; /bin/sh /etc/netstart",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
refreshonly => true,
}
}
debian,ubuntu: {
"debian","ubuntu": {
exec { "restart-network":
cwd => "/etc/network",
command => "cat interfaces.in interfaces.d/*.conf > interfaces && /etc/init.d/networking restart",
@ -63,7 +63,7 @@ class network::hostname {
tag("bootstrap")
case $operatingsystem {
case $::operatingsystem {
"debian","ubuntu": {
file { "/etc/hostname":
ensure => present,
@ -73,7 +73,7 @@ class network::hostname {
group => "root",
}
}
"centos","fedora": {
"centos","redhat","fedora": {
augeas { "set-hostname":
context => "/files/etc/sysconfig/network",
changes => "set HOSTNAME ${homename}",
@ -89,7 +89,7 @@ class network::hostname {
}
}
default: {
fail("network::hostname not supported on ${operatingsystem}")
fail("network::hostname not supported on ${::operatingsystem}")
}
}
@ -156,8 +156,8 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
}
}
case $operatingsystem {
openbsd: {
case $::operatingsystem {
"openbsd": {
file { "/etc/hostname.${name}":
ensure => present,
content => template("network/hostname.if.erb"),
@ -167,7 +167,7 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
notify => Exec["restart-network"],
}
}
centos,fedora: {
"centos","redhat","fedora": {
if $bridge {
network::interface { $bridge:
options => [ "BRIDGE=${name}", "LINKDELAY=10" ],
@ -190,7 +190,7 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
require => File["/etc/sysconfig/network-scripts/ifcfg-${name}"],
}
}
debian,ubuntu: {
"debian","ubuntu": {
include network::helper::debian
file { "/etc/network/interfaces.d/${name}-addr.conf":
ensure => present,
@ -212,7 +212,7 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
@ -236,8 +236,8 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
case $name {
"default": {
case $operatingsystem {
centos,fedora: {
case $::operatingsystem {
"centos","redhat","fedora": {
include network::helper::restart
if "${gateway}" != "" {
augeas { "set-default-route":
@ -284,7 +284,7 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
}
@ -292,8 +292,8 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
if $ipv6gateway != "" {
fail("Custom IPv6 routes not supported yet.")
}
case $operatingsystem {
"fedora","centos": {
case $::operatingsystem {
"fedora","centos","redhat": {
include network::helper::restart
file { "/etc/sysconfig/network-scripts/route-${device}":
ensure => present,
@ -305,7 +305,7 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
}
}
default: {
fail("Custom routes not supported in ${operatingsystem}")
fail("Custom routes not supported in ${::operatingsystem}")
}
}
}
@ -338,8 +338,8 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
# }
#
define network::carp($password, $ipaddr, $netmask, $options = []) {
case $operatingsystem {
openbsd: {
case $::operatingsystem {
"openbsd": {
network::interface { "carp${name}":
ipaddr => $ipaddr,
netmask => $netmask,
@ -347,7 +347,7 @@ define network::carp($password, $ipaddr, $netmask, $options = []) {
postcmd => [ "/usr/sbin/ndp -i carp${name} -- -accept_rtadv" ],
}
}
centos,fedora: {
"centos","redhat","fedora": {
include network::ucarp
file { "/etc/ucarp/vip-${name}.conf":
ensure => present,
@ -360,7 +360,7 @@ define network::carp($password, $ipaddr, $netmask, $options = []) {
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
}
@ -402,7 +402,7 @@ define network::pppoe($username, $password, $device, $authtype = "pap") {
include network::helper::restart
case $operatingsystem {
case $::operatingsystem {
openbsd: {
file { "/etc/hostname.${name}":
ensure => present,
@ -414,7 +414,7 @@ define network::pppoe($username, $password, $device, $authtype = "pap") {
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
@ -445,8 +445,8 @@ define network::pppoe($username, $password, $device, $authtype = "pap") {
# }
#
define network::trunk($devices, $mode = 0, $ipaddr = "none", $netmask = "none", $options = []) {
case $operatingsystem {
centos,fedora: {
case $::operatingsystem {
"centos","redhat","fedora": {
file { "/etc/modprobe.d/${name}.conf":
ensure => present,
content => "alias ${name} bonding\noptions ${name} miimon=100 mode=${mode}\n",
@ -466,7 +466,7 @@ define network::trunk($devices, $mode = 0, $ipaddr = "none", $netmask = "none",
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
}
@ -477,8 +477,8 @@ define network::trunk($devices, $mode = 0, $ipaddr = "none", $netmask = "none",
# This class is automatically included when needed.
#
class network::helper::vlan {
case $operatingsystem {
centos,fedora: {
case $::operatingsystem {
"centos","redhat","fedora": {
augeas { "enable-vlan-support":
context => "/files/etc/sysconfig/network",
changes => "set VLAN yes",
@ -513,15 +513,15 @@ class network::helper::vlan {
#
define network::vlan($device, $ipaddr = "none", $netmask = "none",
$options = []) {
case $operatingsystem {
openbsd: {
case $::operatingsystem {
"openbsd": {
network::interface { "vlan${name}":
options => [ "vlandev ${device}" ],
ipaddr => $ipaddr,
netmask => $netmask,
}
}
centos,fedora: {
"centos","redhat","fedora": {
include network::helper::vlan
network::interface { "${device}.${name}":
ipaddr => $ipaddr,
@ -531,7 +531,7 @@ define network::vlan($device, $ipaddr = "none", $netmask = "none",
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
fail("Network module not supported in ${::operatingsystem}")
}
}
}
@ -541,7 +541,7 @@ define network::vlan($device, $ipaddr = "none", $netmask = "none",
#
class network::manager::disable {
case $operatingsystem {
case $::operatingsystem {
ubuntu: {
file { "/etc/init/network-manager.conf":
ensure => present,
@ -557,7 +557,7 @@ class network::manager::disable {
}
service { "network-manager":
name => $operatingsystem ? {
name => $::operatingsystem ? {
ubuntu => "network-manager",
default => "NetworkManager",
},