Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set default restart value; add schedule and default schedule #132

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----

Expand Down
12 changes: 10 additions & 2 deletions manifests/alias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -47,13 +48,19 @@
$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.") }
# Validate our booleans
validate_bool($noaliasrouting)
validate_bool($userctl)
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

include '::network'

network_if_base { $title:
ensure => $ensure,
Expand All @@ -72,5 +79,6 @@
zone => $zone,
metric => $metric,
restart => $restart,
sched => $sched,
}
} # define network::alias
9 changes: 6 additions & 3 deletions manifests/alias/range.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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.") }
Expand Down Expand Up @@ -88,7 +90,8 @@

if $restart {
File["ifcfg-${interface}-range${clonenum_start}"] {
notify => Service['network'],
notify => Service['network'],
schedule => $sched,
}
}

Expand Down
9 changes: 7 additions & 2 deletions manifests/bond.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand All @@ -37,12 +38,15 @@
$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$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

include '::network'

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
Expand All @@ -57,6 +61,7 @@
bonding_opts => $bonding_opts,
zone => $zone,
restart => $restart,
sched => $sched,
}

# Only install "alias bondN bonding" on old OSs that support
Expand Down
9 changes: 7 additions & 2 deletions manifests/bond/bridge.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -39,12 +40,15 @@
$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$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

include '::network'

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
Expand All @@ -59,6 +63,7 @@
bonding_opts => $bonding_opts,
bridge => $bridge,
restart => $restart,
sched => $sched,
}

# Only install "alias bondN bonding" on old OSs that support
Expand Down
11 changes: 8 additions & 3 deletions manifests/bond/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -43,12 +44,15 @@
$zone = undef,
$defroute = undef,
$metric = undef,
$restart = true,
$restart = $::network::restart_default,
$sched = $::network::sched_default,
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

include '::network'

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
Expand All @@ -65,6 +69,7 @@
defroute => $defroute,
metric => $metric,
restart => $restart,
sched => $sched,
}

# Only install "alias bondN bonding" on old OSs that support
Expand Down
9 changes: 6 additions & 3 deletions manifests/bond/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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) {
Expand All @@ -74,7 +76,8 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Service['network'],
schedule => $sched,
}
}
} # define network::bond::slave
9 changes: 7 additions & 2 deletions manifests/bond/static.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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$' ]
Expand All @@ -76,6 +78,8 @@
validate_bool($ipv6init)
validate_bool($ipv6peerdns)

include '::network'

network_if_base { $title:
ensure => $ensure,
ipaddress => $ipaddress,
Expand All @@ -99,6 +103,7 @@
metric => $metric,
restart => $restart,
userctl => $userctl,
sched => $sched,
}

# Only install "alias bondN bonding" on old OSs that support
Expand Down
9 changes: 6 additions & 3 deletions manifests/bridge.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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$' ]
Expand Down Expand Up @@ -80,7 +82,8 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Service['network'],
schedule => $sched,
}
}
} # define network::bridge
9 changes: 6 additions & 3 deletions manifests/bridge/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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$' ]
Expand Down Expand Up @@ -81,7 +83,8 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Service['network'],
schedule => $sched,
}
}
} # define network::bridge::dynamic
9 changes: 6 additions & 3 deletions manifests/bridge/static.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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$' ]
Expand Down Expand Up @@ -125,7 +127,8 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Service['network'],
schedule => $sched,
}
}
} # define network::bridge::static
Loading