diff --git a/README.md b/README.md index 3d167aa..b4842f2 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,32 @@ By default, all changes notify the network service, thus triggering a restart of restart => false, } +Schedule network restarts: + +If restart is true (default), then an optional schedule can be specified for the network restarts by passing the `sched` parameter. The specified schedule must be defined in the catalog separately from the network module. + + network::if::static { 'eth0': + ensure => 'up', + ipaddress => '1.2.3.4', + netmask => '255.255.255.0', + sched => 'after_hours', + } + +Defaults for restart and/or schedule: +By default, network restarts are enabled (true) and schedules are not set (undef). The defaults can be overridden for all resources by passing the `restart_default` and/or `sched_default` parameters for the network class. + +Code Example: + class {'network': + restart_default => false, + sched_default => 'myschedule', + } + +Hiera Example: + network::restart_default: false + network::sched_default: myschedule + +The defaults can be overridden normally in specific network resources by using the `restart` and/or `sched` parameters. As before, the schedule only applies in cases where restart is true. + Hiera ----- diff --git a/manifests/alias.pp b/manifests/alias.pp index a9e9e82..2fa7e3e 100644 --- a/manifests/alias.pp +++ b/manifests/alias.pp @@ -13,7 +13,8 @@ # $userctl - optional - defaults to false # $zone - optional # $metric - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -47,7 +48,8 @@ $userctl = false, $zone = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our data if ! is_ip_address($ipaddress) { fail("${ipaddress} is not an IP address.") } @@ -72,5 +74,6 @@ zone => $zone, metric => $metric, restart => $restart, + schedule => $sched, } } # define network::alias diff --git a/manifests/alias/range.pp b/manifests/alias/range.pp index 4746d94..6afd99e 100644 --- a/manifests/alias/range.pp +++ b/manifests/alias/range.pp @@ -10,9 +10,10 @@ # $ipaddress_start - required # $clonenum_start - required # $noaliasrouting - optional - false|true -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) # $netmask - optional - an IP address (CIDR not supported) # $broadcast - optional - an IP address +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -43,10 +44,11 @@ $ipaddress_end, $clonenum_start, $noaliasrouting = false, - $restart = true, + $restart = $::network::restart_default, $netmask = false, $broadcast = false, $arpcheck = true, + $sched = $::network::sched_default, ) { # Validate our data if ! is_ip_address($ipaddress_start) { fail("${ipaddress_start} is not an IP address.") } @@ -88,7 +90,8 @@ if $restart { File["ifcfg-${interface}-range${clonenum_start}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } diff --git a/manifests/bond.pp b/manifests/bond.pp index afc1a0a..450c0dd 100644 --- a/manifests/bond.pp +++ b/manifests/bond.pp @@ -10,7 +10,8 @@ # $ethtool_opts - optional # $bonding_opts - optional # $zone - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -37,7 +38,8 @@ $ethtool_opts = undef, $bonding_opts = 'miimon=100', $zone = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -57,6 +59,7 @@ bonding_opts => $bonding_opts, zone => $zone, restart => $restart, + schedule => $sched, } # Only install "alias bondN bonding" on old OSs that support diff --git a/manifests/bond/bridge.pp b/manifests/bond/bridge.pp index 5381e4c..70535ac 100644 --- a/manifests/bond/bridge.pp +++ b/manifests/bond/bridge.pp @@ -9,7 +9,8 @@ # $mtu - optional # $ethtool_opts - optional # $bonding_opts - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -39,7 +40,8 @@ $mtu = undef, $ethtool_opts = undef, $bonding_opts = 'miimon=100', - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -59,6 +61,7 @@ bonding_opts => $bonding_opts, bridge => $bridge, restart => $restart, + schedule => $sched, } # Only install "alias bondN bonding" on old OSs that support diff --git a/manifests/bond/dynamic.pp b/manifests/bond/dynamic.pp index 65e3dbd..1e82bd8 100644 --- a/manifests/bond/dynamic.pp +++ b/manifests/bond/dynamic.pp @@ -13,8 +13,9 @@ # $zone - optional # $metric - optional # $defroute - optional -# $restart - optional - defaults to true - +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) +# # # === Actions: # @@ -43,7 +44,8 @@ $zone = undef, $defroute = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -65,6 +67,7 @@ defroute => $defroute, metric => $metric, restart => $restart, + schedule => $sched, } # Only install "alias bondN bonding" on old OSs that support diff --git a/manifests/bond/slave.pp b/manifests/bond/slave.pp index 8784584..959357b 100644 --- a/manifests/bond/slave.pp +++ b/manifests/bond/slave.pp @@ -7,13 +7,14 @@ # $master - required # $macaddress - optional # $ethtool_opts - optional -# $restart - optional, defaults to true +# $restart - optional - defaults to $::network::restart_default (true) # $zone - optional # $defroute - optional # $metric - optional # $userctl - optional - defaults to false # $bootproto - optional # $onboot - optional +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -45,10 +46,11 @@ $zone = undef, $defroute = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, $userctl = false, $bootproto = undef, $onboot = undef, + $sched = $::network::sched_default, ) { # Validate our data if $macaddress and ! is_mac_address($macaddress) { @@ -74,7 +76,8 @@ if $restart { File["ifcfg-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network::bond::slave diff --git a/manifests/bond/static.pp b/manifests/bond/static.pp index 0f28f52..ba83b61 100644 --- a/manifests/bond/static.pp +++ b/manifests/bond/static.pp @@ -14,9 +14,10 @@ # $bonding_opts - optional # $zone - optional # $defroute - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) # $metric - optional # $userctl - optional +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -59,8 +60,9 @@ $zone = undef, $defroute = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, $userctl = undef, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -99,6 +101,7 @@ metric => $metric, restart => $restart, userctl => $userctl, + schedule => $sched, } # Only install "alias bondN bonding" on old OSs that support diff --git a/manifests/bridge.pp b/manifests/bridge.pp index acb2102..d280b3d 100644 --- a/manifests/bridge.pp +++ b/manifests/bridge.pp @@ -9,7 +9,8 @@ # $stp - optional - defaults to false # $delay - optional - defaults to 30 # $bridging_opts - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -39,7 +40,8 @@ $delay = '30', $bridging_opts = undef, $ipv6init = false, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -80,7 +82,8 @@ if $restart { File["ifcfg-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network::bridge diff --git a/manifests/bridge/dynamic.pp b/manifests/bridge/dynamic.pp index 729d464..09fb37f 100644 --- a/manifests/bridge/dynamic.pp +++ b/manifests/bridge/dynamic.pp @@ -10,7 +10,8 @@ # $stp - optional - defaults to false # $delay - optional - defaults to 30 # $bridging_opts - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -42,7 +43,8 @@ $stp = false, $delay = '30', $bridging_opts = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -81,7 +83,8 @@ if $restart { File["ifcfg-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network::bridge::dynamic diff --git a/manifests/bridge/static.pp b/manifests/bridge/static.pp index 95b3a47..acbd79d 100644 --- a/manifests/bridge/static.pp +++ b/manifests/bridge/static.pp @@ -21,7 +21,8 @@ # $delay - optional - defaults to 30 # $bridging_opts - optional # $scope - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -68,7 +69,8 @@ $delay = '30', $bridging_opts = undef, $scope = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -125,7 +127,8 @@ if $restart { File["ifcfg-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network::bridge::static diff --git a/manifests/global.pp b/manifests/global.pp index 9ff8c67..b29ba4b 100644 --- a/manifests/global.pp +++ b/manifests/global.pp @@ -25,6 +25,7 @@ # $nozeroconf - optional # $restart - optional - defaults to true # $requestreopen - optional - defaults to true +# $sched - optional # # === Actions: # @@ -73,6 +74,7 @@ $nozeroconf = undef, $restart = true, $requestreopen = true, + $sched = undef, ) { # Validate our data if $gateway { @@ -129,7 +131,8 @@ if $restart { File['network.sysconfig'] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # class global diff --git a/manifests/if.pp b/manifests/if.pp index 990a022..55c6472 100644 --- a/manifests/if.pp +++ b/manifests/if.pp @@ -13,7 +13,8 @@ # $scope - optional # $flush - optional - defaults to false # $zone - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -43,7 +44,8 @@ $scope = undef, $flush = false, $zone = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -80,5 +82,6 @@ flush => $flush, zone => $zone, restart => $restart, + schedule => $sched, } } # define network::if diff --git a/manifests/if/bridge.pp b/manifests/if/bridge.pp index b8eef61..e0caf7a 100644 --- a/manifests/if/bridge.pp +++ b/manifests/if/bridge.pp @@ -9,7 +9,8 @@ # $mtu - optional # $ethtool_opts - optional # $macaddress - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -36,7 +37,8 @@ $mtu = undef, $ethtool_opts = undef, $macaddress = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -62,5 +64,6 @@ ethtool_opts => $ethtool_opts, bridge => $bridge, restart => $restart, + schedule => $sched, } } # define network::if::bridge diff --git a/manifests/if/dynamic.pp b/manifests/if/dynamic.pp index 1bc4b16..2f58285 100644 --- a/manifests/if/dynamic.pp +++ b/manifests/if/dynamic.pp @@ -18,7 +18,8 @@ # $zone - optional # $metric - optional # $defroute - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -60,7 +61,8 @@ $defroute = undef, $zone = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -97,5 +99,6 @@ zone => $zone, metric => $metric, restart => $restart, + schedule => $sched, } } # define network::if::dynamic diff --git a/manifests/if/promisc.pp b/manifests/if/promisc.pp index 291cdd6..bd8c9b6 100644 --- a/manifests/if/promisc.pp +++ b/manifests/if/promisc.pp @@ -5,13 +5,15 @@ # === Parameters: # # $ensure - required - up|down -# $macaddress - optional, defaults to macaddress_$title +# $macaddress - optional - defaults to macaddress_$title # $manage_hwaddr - optional - defaults to true -# $bootproto - optional, defaults to undef ('none') +# $bootproto - optional - defaults to undef ('none') # $userctl - optional # $mtu - optional # $ethtool_opts - optional +# $restart - optional - defaults to $::network::restart_default (true) # $promisc - defaults to true +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -48,8 +50,9 @@ $userctl = false, $mtu = undef, $ethtool_opts = undef, - $restart = true, + $restart = $::network::restart_default, $promisc = true, + $sched = $::network::sched_default, ) { include '::network' @@ -154,6 +157,8 @@ ipv6gateway => '', mtu => $mtu, ethtool_opts => $ethtool_opts, + restart => $restart, promisc => $promisc, + schedule => $sched, } } # define network::if::promisc diff --git a/manifests/if/static.pp b/manifests/if/static.pp index b32ccb6..10453a5 100644 --- a/manifests/if/static.pp +++ b/manifests/if/static.pp @@ -27,8 +27,9 @@ # $zone - optional # $metric - optional # $defroute - optional -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) # $arpcheck - optional - defaults to true +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -80,8 +81,9 @@ $zone = undef, $defroute = undef, $metric = undef, - $restart = true, + $restart = $::network::restart_default, $arpcheck = true, + $sched = $::network::sched_default, ) { # Validate our data if $ipaddress { @@ -148,5 +150,6 @@ metric => $metric, restart => $restart, arpcheck => $arpcheck, + schedule => $sched, } } # define network::if::static diff --git a/manifests/init.pp b/manifests/init.pp index 6e3798f..546bf67 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -22,7 +22,10 @@ # # Copyright (C) 2011 Mike Arnold, unless otherwise noted. # -class network { +class network ( + $restart_default = true, + $sched_default = undef, +) { # Only run on RedHat derived systems. case $::osfamily { 'RedHat': { } @@ -77,8 +80,9 @@ # $metric - optional # $defroute - optional # $promisc - optional - defaults to false -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) # $arpcheck - optional - defaults to true +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -138,8 +142,9 @@ $zone = undef, $metric = undef, $promisc = false, - $restart = true, + $restart = $::network::restart_default, $arpcheck = true, + $sched = $::network::sched_default, ) { # Validate our booleans validate_bool($noaliasrouting) @@ -215,7 +220,8 @@ if $restart { File["ifcfg-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network_if_base diff --git a/manifests/route.pp b/manifests/route.pp index 27c7534..ae04840 100644 --- a/manifests/route.pp +++ b/manifests/route.pp @@ -7,7 +7,8 @@ # $ipaddress - required # $netmask - required # $gateway - required -# $restart - optional - defaults to true +# $restart - optional - defaults to $::network::restart_default (true) +# $sched - optional - defaults to $::network::sched_default (undef) # # === Actions: # @@ -44,7 +45,8 @@ $ipaddress, $netmask, $gateway, - $restart = true, + $restart = $::network::restart_default, + $sched = $::network::sched_default, ) { # Validate our arrays validate_array($ipaddress) @@ -69,7 +71,8 @@ if $restart { File["route-${interface}"] { - notify => Service['network'], + notify => Service['network'], + schedule => $sched, } } } # define network::route