Skip to content

Commit d0e041e

Browse files
committed
Add ability to set a default restart value ( restart_default, boolean); add schedule and default schedule options to enable network restarts during change windows
1 parent 106d300 commit d0e041e

19 files changed

+130
-45
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,32 @@ By default, all changes notify the network service, thus triggering a restart of
293293
restart => false,
294294
}
295295

296+
Schedule network restarts:
297+
298+
If restart is true (default), then an optional schedule can be specified for the network restarts. The schedule must be defined in the catalog separately from the network module.
299+
300+
network::if::static { 'eth0':
301+
ensure => 'up',
302+
ipaddress => '1.2.3.4',
303+
netmask => '255.255.255.0',
304+
schedule => 'after_hours',
305+
}
306+
307+
Defaults for restart and/or schedule:
308+
By default, network restarts are enabled (true) and schedules are not set (undef). The defaults can be overridden for all resources by setting:
309+
310+
Code Example:
311+
class {'network':
312+
restart_default => false,
313+
schedule_default => 'myschedule',
314+
}
315+
316+
Hiera Example:
317+
network::restart_default: false
318+
network::schedule_default: myschedule
319+
320+
The defaults can be overridden normally in specific network resources. As before, schedule only applies in cases where restart is true.
321+
296322
Hiera
297323
-----
298324

manifests/alias.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# $userctl - optional - defaults to false
1414
# $zone - optional
1515
# $metric - optional
16-
# $restart - optional - defaults to true
16+
# $restart - optional - defaults to $::network::restart_default (true)
17+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1718
#
1819
# === Actions:
1920
#
@@ -47,7 +48,8 @@
4748
$userctl = false,
4849
$zone = undef,
4950
$metric = undef,
50-
$restart = true,
51+
$restart = $::network::restart_default,
52+
$schedule = $::network::schedule_default,
5153
) {
5254
# Validate our data
5355
if ! is_ip_address($ipaddress) { fail("${ipaddress} is not an IP address.") }
@@ -72,5 +74,6 @@
7274
zone => $zone,
7375
metric => $metric,
7476
restart => $restart,
77+
schedule => $schedule,
7578
}
7679
} # define network::alias

manifests/alias/range.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
# $ipaddress_start - required
1111
# $clonenum_start - required
1212
# $noaliasrouting - optional - false|true
13-
# $restart - optional - defaults to true
13+
# $restart - optional - defaults to $::network::restart_default (true)
1414
# $netmask - optional - an IP address (CIDR not supported)
1515
# $broadcast - optional - an IP address
16+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1617
#
1718
# === Actions:
1819
#
@@ -43,10 +44,11 @@
4344
$ipaddress_end,
4445
$clonenum_start,
4546
$noaliasrouting = false,
46-
$restart = true,
47+
$restart = $::network::restart_default,
4748
$netmask = false,
4849
$broadcast = false,
4950
$arpcheck = true,
51+
$schedule = $::network::schedule_default,
5052
) {
5153
# Validate our data
5254
if ! is_ip_address($ipaddress_start) { fail("${ipaddress_start} is not an IP address.") }
@@ -88,7 +90,8 @@
8890

8991
if $restart {
9092
File["ifcfg-${interface}-range${clonenum_start}"] {
91-
notify => Service['network'],
93+
notify => Service['network'],
94+
schedule => $schedule,
9295
}
9396
}
9497

manifests/bond.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# $ethtool_opts - optional
1111
# $bonding_opts - optional
1212
# $zone - optional
13-
# $restart - optional - defaults to true
13+
# $restart - optional - defaults to $::network::restart_default (true)
14+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1415
#
1516
# === Actions:
1617
#
@@ -37,7 +38,8 @@
3738
$ethtool_opts = undef,
3839
$bonding_opts = 'miimon=100',
3940
$zone = undef,
40-
$restart = true,
41+
$restart = $::network::restart_default,
42+
$schedule = $::network::schedule_default,
4143
) {
4244
# Validate our regular expressions
4345
$states = [ '^up$', '^down$' ]
@@ -57,6 +59,7 @@
5759
bonding_opts => $bonding_opts,
5860
zone => $zone,
5961
restart => $restart,
62+
schedule => $schedule,
6063
}
6164

6265
# Only install "alias bondN bonding" on old OSs that support

manifests/bond/bridge.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
# $mtu - optional
1010
# $ethtool_opts - optional
1111
# $bonding_opts - optional
12-
# $restart - optional - defaults to true
12+
# $restart - optional - defaults to $::network::restart_default (true)
13+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1314
#
1415
# === Actions:
1516
#
@@ -39,7 +40,8 @@
3940
$mtu = undef,
4041
$ethtool_opts = undef,
4142
$bonding_opts = 'miimon=100',
42-
$restart = true,
43+
$restart = $::network::restart_default,
44+
$schedule = $::network::schedule_default,
4345
) {
4446
# Validate our regular expressions
4547
$states = [ '^up$', '^down$' ]
@@ -59,6 +61,7 @@
5961
bonding_opts => $bonding_opts,
6062
bridge => $bridge,
6163
restart => $restart,
64+
schedule => $schedule,
6265
}
6366

6467
# Only install "alias bondN bonding" on old OSs that support

manifests/bond/dynamic.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
# $zone - optional
1414
# $metric - optional
1515
# $defroute - optional
16-
# $restart - optional - defaults to true
17-
16+
# $restart - optional - defaults to $::network::restart_default (true)
17+
# $schedule - optional - defaults to $::network::schedule_default (undef)
18+
#
1819
#
1920
# === Actions:
2021
#
@@ -43,7 +44,8 @@
4344
$zone = undef,
4445
$defroute = undef,
4546
$metric = undef,
46-
$restart = true,
47+
$restart = $::network::restart_default,
48+
$schedule = $::network::schedule_default,
4749
) {
4850
# Validate our regular expressions
4951
$states = [ '^up$', '^down$' ]
@@ -65,6 +67,7 @@
6567
defroute => $defroute,
6668
metric => $metric,
6769
restart => $restart,
70+
schedule => $schedule,
6871
}
6972

7073
# Only install "alias bondN bonding" on old OSs that support

manifests/bond/slave.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
# $master - required
88
# $macaddress - optional
99
# $ethtool_opts - optional
10-
# $restart - optional, defaults to true
10+
# $restart - optional - defaults to $::network::restart_default (true)
1111
# $zone - optional
1212
# $defroute - optional
1313
# $metric - optional
1414
# $userctl - optional - defaults to false
1515
# $bootproto - optional
1616
# $onboot - optional
17+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1718
#
1819
# === Actions:
1920
#
@@ -45,10 +46,11 @@
4546
$zone = undef,
4647
$defroute = undef,
4748
$metric = undef,
48-
$restart = true,
49+
$restart = $::network::restart_default,
4950
$userctl = false,
5051
$bootproto = undef,
5152
$onboot = undef,
53+
$schedule = $::network::schedule_default,
5254
) {
5355
# Validate our data
5456
if $macaddress and ! is_mac_address($macaddress) {
@@ -74,7 +76,8 @@
7476

7577
if $restart {
7678
File["ifcfg-${interface}"] {
77-
notify => Service['network'],
79+
notify => Service['network'],
80+
schedule => $schedule,
7881
}
7982
}
8083
} # define network::bond::slave

manifests/bond/static.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# $bonding_opts - optional
1515
# $zone - optional
1616
# $defroute - optional
17-
# $restart - optional - defaults to true
17+
# $restart - optional - defaults to $::network::restart_default (true)
1818
# $metric - optional
1919
# $userctl - optional
20+
# $schedule - optional - defaults to $::network::schedule_default (undef)
2021
#
2122
# === Actions:
2223
#
@@ -59,8 +60,9 @@
5960
$zone = undef,
6061
$defroute = undef,
6162
$metric = undef,
62-
$restart = true,
63+
$restart = $::network::restart_default,
6364
$userctl = undef,
65+
$schedule = $::network::schedule_default,
6466
) {
6567
# Validate our regular expressions
6668
$states = [ '^up$', '^down$' ]
@@ -99,6 +101,7 @@
99101
metric => $metric,
100102
restart => $restart,
101103
userctl => $userctl,
104+
schedule => $schedule,
102105
}
103106

104107
# Only install "alias bondN bonding" on old OSs that support

manifests/bridge.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
# $stp - optional - defaults to false
1010
# $delay - optional - defaults to 30
1111
# $bridging_opts - optional
12-
# $restart - optional - defaults to true
12+
# $restart - optional - defaults to $::network::restart_default (true)
13+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1314
#
1415
# === Actions:
1516
#
@@ -39,7 +40,8 @@
3940
$delay = '30',
4041
$bridging_opts = undef,
4142
$ipv6init = false,
42-
$restart = true,
43+
$restart = $::network::restart_default,
44+
$schedule = $::network::schedule_default,
4345
) {
4446
# Validate our regular expressions
4547
$states = [ '^up$', '^down$' ]
@@ -80,7 +82,8 @@
8082

8183
if $restart {
8284
File["ifcfg-${interface}"] {
83-
notify => Service['network'],
85+
notify => Service['network'],
86+
schedule => $schedule,
8487
}
8588
}
8689
} # define network::bridge

manifests/bridge/dynamic.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# $stp - optional - defaults to false
1111
# $delay - optional - defaults to 30
1212
# $bridging_opts - optional
13-
# $restart - optional - defaults to true
13+
# $restart - optional - defaults to $::network::restart_default (true)
14+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1415
#
1516
# === Actions:
1617
#
@@ -42,7 +43,8 @@
4243
$stp = false,
4344
$delay = '30',
4445
$bridging_opts = undef,
45-
$restart = true,
46+
$restart = $::network::restart_default,
47+
$schedule = $::network::schedule_default,
4648
) {
4749
# Validate our regular expressions
4850
$states = [ '^up$', '^down$' ]
@@ -81,7 +83,8 @@
8183

8284
if $restart {
8385
File["ifcfg-${interface}"] {
84-
notify => Service['network'],
86+
notify => Service['network'],
87+
schedule => $schedule,
8588
}
8689
}
8790
} # define network::bridge::dynamic

manifests/bridge/static.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# $delay - optional - defaults to 30
2222
# $bridging_opts - optional
2323
# $scope - optional
24-
# $restart - optional - defaults to true
24+
# $restart - optional - defaults to $::network::restart_default (true)
25+
# $schedule - optional - defaults to $::network::schedule_default (undef)
2526
#
2627
# === Actions:
2728
#
@@ -68,7 +69,8 @@
6869
$delay = '30',
6970
$bridging_opts = undef,
7071
$scope = undef,
71-
$restart = true,
72+
$restart = $::network::restart_default,
73+
$schedule = $::network::schedule_default,
7274
) {
7375
# Validate our regular expressions
7476
$states = [ '^up$', '^down$' ]
@@ -125,7 +127,8 @@
125127

126128
if $restart {
127129
File["ifcfg-${interface}"] {
128-
notify => Service['network'],
130+
notify => Service['network'],
131+
schedule => $schedule,
129132
}
130133
}
131134
} # define network::bridge::static

manifests/global.pp

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# $nozeroconf - optional
2626
# $restart - optional - defaults to true
2727
# $requestreopen - optional - defaults to true
28+
# $schedule - optional
2829
#
2930
# === Actions:
3031
#
@@ -73,6 +74,7 @@
7374
$nozeroconf = undef,
7475
$restart = true,
7576
$requestreopen = true,
77+
$schedule = undef,
7678
) {
7779
# Validate our data
7880
if $gateway {
@@ -129,7 +131,8 @@
129131

130132
if $restart {
131133
File['network.sysconfig'] {
132-
notify => Service['network'],
134+
notify => Service['network'],
135+
schedule => $schedule,
133136
}
134137
}
135138
} # class global

manifests/if.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# $scope - optional
1414
# $flush - optional - defaults to false
1515
# $zone - optional
16-
# $restart - optional - defaults to true
16+
# $restart - optional - defaults to $::network::restart_default (true)
17+
# $schedule - optional - defaults to $::network::schedule_default (undef)
1718
#
1819
# === Actions:
1920
#
@@ -43,7 +44,8 @@
4344
$scope = undef,
4445
$flush = false,
4546
$zone = undef,
46-
$restart = true,
47+
$restart = $::network::restart_default,
48+
$schedule = $::network::schedule_default,
4749
) {
4850
# Validate our regular expressions
4951
$states = [ '^up$', '^down$' ]
@@ -80,5 +82,6 @@
8082
flush => $flush,
8183
zone => $zone,
8284
restart => $restart,
85+
schedule => $schedule,
8386
}
8487
} # define network::if

0 commit comments

Comments
 (0)