network: Lint and style fixes
This commit is contained in:
parent
d314f408c5
commit
f0ba468fcc
1 changed files with 73 additions and 39 deletions
|
@ -1,9 +1,9 @@
|
|||
|
||||
# Class which restarts networking if needed.
|
||||
#
|
||||
# This class is automatically included when needed.
|
||||
#
|
||||
class network::helper::restart {
|
||||
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
exec { "restart-network":
|
||||
|
@ -27,7 +27,9 @@ class network::helper::restart {
|
|||
refreshonly => true,
|
||||
}
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,21 +156,29 @@ class network::hostname {
|
|||
# netmask => "255.255.0.0",
|
||||
# }
|
||||
#
|
||||
define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
|
||||
$dnsnameservers = "none", $dnssearch = "none",
|
||||
$ip6addr = "none", $ip6netmask = "64",
|
||||
$bridge = [], $options = [], $postcmd = []) {
|
||||
define network::interface(
|
||||
$ipaddr="none",
|
||||
$eaddr="none",
|
||||
$netmask="none",
|
||||
$dnsnameservers="none",
|
||||
$dnssearch="none",
|
||||
$ip6addr="none",
|
||||
$ip6netmask="64",
|
||||
$bridge=[],
|
||||
$options=[],
|
||||
$postcmd=[]
|
||||
) {
|
||||
|
||||
include network::helper::restart
|
||||
|
||||
# try to determine boot protocol from ip address
|
||||
case $ipaddr {
|
||||
dhcp: { $proto = "dhcp" }
|
||||
none: { $proto = "none" }
|
||||
"dhcp": { $proto = "dhcp" }
|
||||
"none": { $proto = "none" }
|
||||
default: {
|
||||
$proto = "static"
|
||||
case $netmask {
|
||||
none: { fail("Netmask must be defined with ip address") }
|
||||
if $netmask == "none" {
|
||||
fail("Netmask must be defined with ip address")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,28 +261,28 @@ define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
|
|||
#
|
||||
# $name:
|
||||
# Destination network or default for default route.
|
||||
# $device:
|
||||
# Interface to use for this route.
|
||||
# $gateway:
|
||||
# Gateway address.
|
||||
# $ipv6gateway:
|
||||
# IPv6 gateway address.
|
||||
# $device:
|
||||
# Interface to use for this route.
|
||||
#
|
||||
define network::route($gateway = "", $device, $ipv6gateway = "") {
|
||||
define network::route($device, $gateway="", $ipv6gateway="") {
|
||||
|
||||
case $name {
|
||||
"default": {
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
include network::helper::restart
|
||||
if "${gateway}" != "" {
|
||||
if $gateway != "" {
|
||||
augeas { "set-default-route":
|
||||
context => "/files/etc/sysconfig/network",
|
||||
changes => "set GATEWAY ${gateway}",
|
||||
notify => Exec["restart-network"],
|
||||
}
|
||||
}
|
||||
if "${ipv6gateway}" != "" {
|
||||
if $ipv6gateway != "" {
|
||||
augeas { "set-default-ipv6-route":
|
||||
context => "/files/etc/sysconfig/network",
|
||||
changes => "set IPV6_DEFAULTGW ${ipv6gateway}",
|
||||
|
@ -285,7 +295,7 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
|
|||
notify => Exec["restart-network"],
|
||||
}
|
||||
}
|
||||
openbsd: {
|
||||
"openbsd": {
|
||||
include network::helper::restart
|
||||
file { "/etc/mygate":
|
||||
ensure => present,
|
||||
|
@ -296,7 +306,7 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
|
|||
notify => Exec["restart-network"],
|
||||
}
|
||||
}
|
||||
debian,ubuntu: {
|
||||
"debian","ubuntu": {
|
||||
include network::helper::restart
|
||||
include network::helper::debian
|
||||
file { "/etc/network/interfaces.d/${device}-gate.conf":
|
||||
|
@ -363,7 +373,8 @@ define network::route($gateway = "", $device, $ipv6gateway = "") {
|
|||
# password => "secret",
|
||||
# }
|
||||
#
|
||||
define network::carp($password, $ipaddr, $netmask, $options = [], $postcmd = []) {
|
||||
define network::carp($password, $ipaddr, $netmask, $options=[], $postcmd=[]) {
|
||||
|
||||
case $::operatingsystem {
|
||||
"openbsd": {
|
||||
$carp_options = [ "vhid ${name}", "pass ${password}" ]
|
||||
|
@ -391,6 +402,7 @@ define network::carp($password, $ipaddr, $netmask, $options = [], $postcmd = [])
|
|||
fail("Network module not supported in ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -399,6 +411,7 @@ define network::carp($password, $ipaddr, $netmask, $options = [], $postcmd = [])
|
|||
# This class is automatically included by network::carp when needed.
|
||||
#
|
||||
class network::ucarp {
|
||||
|
||||
package { "ucarp":
|
||||
ensure => installed,
|
||||
}
|
||||
|
@ -408,6 +421,7 @@ class network::ucarp {
|
|||
hasstatus => true,
|
||||
require => Package["ucarp"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -426,7 +440,7 @@ class network::ucarp {
|
|||
# $authtype:
|
||||
# Authentication method to use. Defaults to PAP.
|
||||
#
|
||||
define network::pppoe($username, $password, $device, $authtype = "pap") {
|
||||
define network::pppoe($username, $password, $device, $authtype="pap") {
|
||||
|
||||
include network::helper::restart
|
||||
|
||||
|
@ -472,7 +486,14 @@ define network::pppoe($username, $password, $device, $authtype = "pap") {
|
|||
# netmask => "255.255.0.0",
|
||||
# }
|
||||
#
|
||||
define network::trunk($devices, $mode = 0, $ipaddr = "none", $netmask = "none", $options = []) {
|
||||
define network::trunk(
|
||||
$devices,
|
||||
$mode="0",
|
||||
$ipaddr="none",
|
||||
$netmask="none",
|
||||
$options=[]
|
||||
) {
|
||||
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
file { "/etc/modprobe.d/${name}.conf":
|
||||
|
@ -505,6 +526,7 @@ define network::trunk($devices, $mode = 0, $ipaddr = "none", $netmask = "none",
|
|||
# This class is automatically included when needed.
|
||||
#
|
||||
class network::helper::vlan {
|
||||
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
augeas { "enable-vlan-support":
|
||||
|
@ -512,7 +534,9 @@ class network::helper::vlan {
|
|||
changes => "set VLAN yes",
|
||||
}
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -539,8 +563,13 @@ class network::helper::vlan {
|
|||
# netmask => "255.255.0.0",
|
||||
# }
|
||||
#
|
||||
define network::vlan($device, $ipaddr = "none", $netmask = "none",
|
||||
$options = []) {
|
||||
define network::vlan(
|
||||
$device,
|
||||
$ipaddr="none",
|
||||
$netmask = "none",
|
||||
$options=[]
|
||||
) {
|
||||
|
||||
case $::operatingsystem {
|
||||
"openbsd": {
|
||||
network::interface { "vlan${name}":
|
||||
|
@ -562,6 +591,7 @@ define network::vlan($device, $ipaddr = "none", $netmask = "none",
|
|||
fail("Network module not supported in ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -569,33 +599,32 @@ define network::vlan($device, $ipaddr = "none", $netmask = "none",
|
|||
#
|
||||
class network::manager::disable {
|
||||
|
||||
case $::operatingsystem {
|
||||
ubuntu: {
|
||||
file { "/etc/init/network-manager.conf":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => root,
|
||||
group => root,
|
||||
source => "puppet:///modules/network/network-manager.disabled.conf",
|
||||
}
|
||||
xdg::autostart { "nm-applet":
|
||||
enable => false,
|
||||
}
|
||||
if $::operatingsystem == "Ubuntu" {
|
||||
file { "/etc/init/network-manager.conf":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => root,
|
||||
group => root,
|
||||
source => "puppet:///modules/network/network-manager.disabled.conf",
|
||||
}
|
||||
xdg::autostart { "nm-applet":
|
||||
enable => false,
|
||||
}
|
||||
}
|
||||
|
||||
service { "network-manager":
|
||||
ensure => stopped,
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
name => $::operatingsystem ? {
|
||||
ubuntu => "network-manager",
|
||||
default => "NetworkManager",
|
||||
},
|
||||
ensure => stopped,
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Define IPv6 prefixes for advertisement
|
||||
#
|
||||
# === Sample usage
|
||||
|
@ -603,7 +632,10 @@ class network::manager::disable {
|
|||
# network::routeradvertisement::ipv6prefix { "em1":
|
||||
# prefix => "2001:db8:c0de:cafe::/64"
|
||||
# }
|
||||
define network::routeradvertisement::ipv6prefix($prefix = "", $description = "") {
|
||||
define network::routeradvertisement::ipv6prefix(
|
||||
$prefix="",
|
||||
$description=""
|
||||
) {
|
||||
|
||||
case $::operatingsystem {
|
||||
"centos","redhat": {
|
||||
|
@ -644,7 +676,7 @@ define network::routeradvertisement::ipv6prefix($prefix = "", $description = "")
|
|||
}
|
||||
}
|
||||
default: {
|
||||
fail("Router advertisement not supported in $::operatingsystem.")
|
||||
fail("Router advertisement not supported in $::{operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,6 +686,7 @@ define network::routeradvertisement::ipv6prefix($prefix = "", $description = "")
|
|||
# Router Advertisement daemon
|
||||
#
|
||||
class network::routeradvertisement {
|
||||
|
||||
case $::operatingsystem {
|
||||
"centos","redhat": {
|
||||
package { "radvd":
|
||||
|
@ -686,7 +719,8 @@ class network::routeradvertisement {
|
|||
# Only network::ipv6network is needed for OpenBSD
|
||||
}
|
||||
default: {
|
||||
fail("Router advertisement not supported in $::operatingsystem")
|
||||
fail("Router advertisement not supported in $::{operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue