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

Support Puppet 4 and 5 #148

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
497078b
Remove support for Puppet <4.9.0
pmuller Feb 19, 2018
12d3127
Use typing in network::if
pmuller Feb 19, 2018
4f90844
Use lookup() instead of hiera_hash()
pmuller Feb 19, 2018
81cb363
Use typing in network::bridge
pmuller Feb 19, 2018
9505bed
Use typing in network::alias
pmuller Feb 19, 2018
3e67b7a
Use typing in network::alias::range
pmuller Feb 19, 2018
11fcab2
Use typing in network::bond
pmuller Feb 19, 2018
d68acaa
Use typing in network::if::bridge
pmuller Feb 19, 2018
d5e3b71
Use typing in network::if::static
pmuller Feb 19, 2018
62e3a94
Use typing in network::if::promisc
pmuller Feb 19, 2018
674be8e
Use typing in network::if::dynamic
pmuller Feb 19, 2018
a63a23d
Fixures: fix ref for thrnio/ip
pmuller Feb 19, 2018
7b83769
Use typing in network::bond::bridge
pmuller Feb 19, 2018
4d7f15d
Use typing in network::bond::slave
pmuller Feb 19, 2018
046a380
Use typing in network::bond::static
pmuller Feb 19, 2018
7c8e5b3
Use typing in network::bond::dynamic
pmuller Feb 19, 2018
2b7d2f6
Use typing in network::route
pmuller Feb 19, 2018
11de7c1
Use typing in network::global
pmuller Feb 19, 2018
0e95a0c
Use typing in network::bridge::static
pmuller Feb 19, 2018
522959e
Use typing in network::bridge::dynamic
pmuller Feb 19, 2018
6fef947
Use typing in network_if_base
pmuller Feb 19, 2018
43b3bc8
Simplify if statement
pmuller Feb 19, 2018
2131838
Remove useless calls to validate_* functions
pmuller Feb 19, 2018
335a120
Use thrnio/ip types instead of stdlib types
pmuller Feb 19, 2018
020ef28
Prevent rspec output truncation
pmuller Feb 19, 2018
9cc223b
Add type Network::If::Bootproto
pmuller Feb 19, 2018
5f38177
Accept thrnio/ip 1.0.0
pmuller Feb 19, 2018
7bcb6b8
Stop using $::macaddress_* legacy facts
pmuller Feb 19, 2018
220aa34
Stop using $::osfamily and $::operatingsystem* legact facts
pmuller Feb 19, 2018
4fc403b
Remove rspec output truncation hack
pmuller Feb 19, 2018
03c72f5
Tests: no longer allow failures for Puppet 5
pmuller Feb 19, 2018
0834c90
Fix tests for Puppet 4
pmuller Feb 19, 2018
4b69dde
Update README
pmuller Feb 19, 2018
44b0ef4
Use EPP in network::route
pmuller Feb 20, 2018
086ed5c
Use EPP in network_if_base for ifcfg-alias
pmuller Feb 20, 2018
81c922c
Use EPP in network::alias::range
pmuller Feb 20, 2018
a2e133b
Use EPP in network::bond::slave
pmuller Feb 20, 2018
7db97fa
Use EPP in network::bridge
pmuller Feb 20, 2018
647e94f
Use EPP in network::global
pmuller Feb 20, 2018
86a4349
Use EPP in network_if_base for ifcfg-eth
pmuller Feb 20, 2018
c3c6b44
Tests: remove useless facts
pmuller Feb 20, 2018
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
7 changes: 6 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
stdlib:
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.24.0'
ip:
repo: 'https://github.com/thrnio/puppet-ip.git'
ref: 'v1.0.0'
symlinks:
network: "#{source_dir}"
15 changes: 0 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,10 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake
matrix:
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.0"
- rvm: 2.4.1
env: PUPPET_GEM_VERSION="~> 5.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
allow_failures:
- rvm: 2.4.1
env: PUPPET_GEM_VERSION="~> 5.0"
notifications:
email:
- [email protected]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Bonded master interface - bridged (the corresponding network::bridge::* may also
Bonded slave interface:

network::bond::slave { 'eth1':
macaddress => $macaddress_eth1,
macaddress => $::networking['interfaces']['eth1']['mac'],
ethtool_opts => 'autoneg off speed 1000 duplex full',
master => 'bond0',
}
Expand Down Expand Up @@ -322,7 +322,7 @@ The Hiera naming substitutes underscore for any secondary double colons, i.e. sp
Notes
-----

* Runs under Puppet 2.7 and later.
* Runs under Puppet 4.9 and later.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect this module to work on >=4.x but I am not sure what is the best method to validate this belief.

* Only works with RedHat-ish systems.
* Read /usr/share/doc/initscripts-*/sysconfig.txt for underlying details.
* Read /usr/share/doc/kernel-doc-*/Documentation/networking/bonding.txt for underlying details.
Expand Down
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ and remove the interface.

network::bond::dynamic { "bond2":
slaves => [ "eth4", "eth7", ],
macaddress => [ $macaddress_eth4, $macaddress_eth7, ],
macaddress => [
$::networking['interfaces']['eth4']['mac'],
$::networking['interfaces']['eth7']['mac'],
],
bonding_opts => "mode=active-backup",
mtu => "1500",
ethtool_opts => "speed 100 duplex full autoneg off",
Expand Down
30 changes: 11 additions & 19 deletions manifests/alias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,18 @@
# Copyright (C) 2011 Mike Arnold, unless otherwise noted.
#
define network::alias (
$ensure,
$ipaddress,
$netmask,
$gateway = undef,
$noaliasrouting = false,
$ipv6address = undef,
$ipv6gateway = undef,
$userctl = false,
$zone = undef,
$metric = undef,
$restart = true,
Enum['up', 'down'] $ensure,
IP::Address::V4::NoSubnet $ipaddress,
IP::Address::V4::NoSubnet $netmask,
Optional[IP::Address::V4::NoSubnet] $gateway = undef,
Boolean $noaliasrouting = false,
Optional[IP::Address::V6] $ipv6address = undef,
Optional[IP::Address::V6::NoSubnet] $ipv6gateway = undef,
Boolean $userctl = false,
Optional[String] $zone = undef,
Optional[String] $metric = undef,
Boolean $restart = true,
) {
# Validate our data
if ! is_ip_address($ipaddress) { fail("${ipaddress} is not an IP address.") }
# Validate our booleans
validate_bool($noaliasrouting)
validate_bool($userctl)

network_if_base { $title:
ensure => $ensure,
Expand All @@ -63,11 +58,8 @@
noaliasrouting => $noaliasrouting,
ipv6address => $ipv6address,
ipv6gateway => $ipv6gateway,
macaddress => '',
bootproto => 'none',
userctl => $userctl,
mtu => '',
ethtool_opts => '',
isalias => true,
zone => $zone,
metric => $metric,
Expand Down
41 changes: 19 additions & 22 deletions manifests/alias/range.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,16 @@
# Copyright (C) 2013 Mike Arnold, unless otherwise noted.
#
define network::alias::range (
$ensure,
$ipaddress_start,
$ipaddress_end,
$clonenum_start,
$noaliasrouting = false,
$restart = true,
$netmask = false,
$broadcast = false,
$arpcheck = true,
Enum['up', 'down', 'absent'] $ensure,
IP::Address::V4::NoSubnet $ipaddress_start,
IP::Address::V4::NoSubnet $ipaddress_end,
String $clonenum_start,
Boolean $noaliasrouting = false,
Boolean $restart = true,
Optional[IP::Address::V4::NoSubnet] $netmask = undef,
Optional[IP::Address::V4::NoSubnet] $broadcast = undef,
Copy link
Author

@pmuller pmuller Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous default values were misleading, and keeping them would make us accept Boolean for these parameters (doesn't sound like a good idea). This change has no impact on the way templates use the data.

Boolean $arpcheck = true,
) {
# Validate our data
if ! is_ip_address($ipaddress_start) { fail("${ipaddress_start} is not an IP address.") }
if ! is_ip_address($ipaddress_end) { fail("${ipaddress_end} is not an IP address.") }
if $netmask and !is_ip_address($netmask) { fail("${netmask} is not an IP address.") }
if $broadcast and !is_ip_address($broadcast) { fail("${broadcast} is not an IP address.") }
# Validate our booleans
validate_bool($noaliasrouting)
validate_bool($restart)
validate_bool($arpcheck)
# Validate our regular expressions
$states = [ '^up$', '^down$', '^absent$' ]
validate_re($ensure, $states, '$ensure must be either "up", "down", or "absent".')

include '::network'

Expand All @@ -82,7 +70,16 @@
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/ifcfg-${interface}-range${clonenum_start}",
content => template('network/ifcfg-alias-range.erb'),
content => epp("${module_name}/ifcfg-alias-range.epp", {
ipaddress_start => $ipaddress_start,
ipaddress_end => $ipaddress_end,
clonenum_start => $clonenum_start,
noaliasrouting => $noaliasrouting,
netmask => $netmask,
broadcast => $broadcast,
arpcheck => $arpcheck,
onparent => $onparent,
}),
before => File["ifcfg-${interface}"],
}

Expand Down
29 changes: 10 additions & 19 deletions manifests/bond.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,17 @@
# Copyright (C) 2015 Jason Vervlied, unless otherwise noted.
#
define network::bond (
$ensure,
$mtu = undef,
$ethtool_opts = undef,
$bonding_opts = 'miimon=100',
$zone = undef,
$restart = true,
Enum['up', 'down'] $ensure,
Optional[String] $mtu = undef,
Optional[String] $ethtool_opts = undef,
String $bonding_opts = 'miimon=100',
Optional[String] $zone = undef,
Boolean $restart = true,
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => '',
bootproto => 'none',
ipv6address => '',
ipv6gateway => '',
mtu => $mtu,
ethtool_opts => $ethtool_opts,
bonding_opts => $bonding_opts,
Expand All @@ -61,10 +52,10 @@

# Only install "alias bondN bonding" on old OSs that support
# /etc/modprobe.conf.
case $::operatingsystem {
case $::os['name'] {
/^(RedHat|CentOS|OEL|OracleLinux|SLC|Scientific)$/: {
case $::operatingsystemrelease {
/^[45]/: {
case $::os['release']['major'] {
/^[45]$/: {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to major release, as only the "major" part was used.

augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
changes => [
Expand All @@ -79,7 +70,7 @@
}
}
'Fedora': {
case $::operatingsystemrelease {
case $::os['release']['major'] {
/^(1|2|3|4|5|6|7|8|9|10|11)$/: {
augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
Expand Down
29 changes: 10 additions & 19 deletions manifests/bond/bridge.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,17 @@
# Copyright (C) 2013 Mike Arnold, unless otherwise noted.
#
define network::bond::bridge (
$ensure,
$bridge,
$mtu = undef,
$ethtool_opts = undef,
$bonding_opts = 'miimon=100',
$restart = true,
Enum['up', 'down'] $ensure,
String $bridge,
Optional[String] $mtu = undef,
Optional[String] $ethtool_opts = undef,
String $bonding_opts = 'miimon=100',
Boolean $restart = true,
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => '',
bootproto => 'none',
ipv6address => '',
ipv6gateway => '',
mtu => $mtu,
ethtool_opts => $ethtool_opts,
bonding_opts => $bonding_opts,
Expand All @@ -63,10 +54,10 @@

# Only install "alias bondN bonding" on old OSs that support
# /etc/modprobe.conf.
case $::operatingsystem {
case $::os['name'] {
/^(RedHat|CentOS|OEL|OracleLinux|SLC|Scientific)$/: {
case $::operatingsystemrelease {
/^[45]/: {
case $::os['release']['major'] {
/^[45]$/: {
augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
changes => [
Expand All @@ -81,7 +72,7 @@
}
}
'Fedora': {
case $::operatingsystemrelease {
case $::os['release']['major'] {
/^(1|2|3|4|5|6|7|8|9|10|11)$/: {
augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
Expand Down
33 changes: 12 additions & 21 deletions manifests/bond/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,19 @@
# Copyright (C) 2011 Mike Arnold, unless otherwise noted.
#
define network::bond::dynamic (
$ensure,
$mtu = undef,
$ethtool_opts = undef,
$bonding_opts = 'miimon=100',
$zone = undef,
$defroute = undef,
$metric = undef,
$restart = true,
Enum['up', 'down'] $ensure,
Optional[String] $mtu = undef,
Optional[String] $ethtool_opts = undef,
String $bonding_opts = 'miimon=100',
Optional[String] $zone = undef,
Optional[String] $defroute = undef,
Optional[String] $metric = undef,
Boolean $restart = true,
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => '',
bootproto => 'dhcp',
ipv6address => '',
ipv6gateway => '',
mtu => $mtu,
ethtool_opts => $ethtool_opts,
bonding_opts => $bonding_opts,
Expand All @@ -69,10 +60,10 @@

# Only install "alias bondN bonding" on old OSs that support
# /etc/modprobe.conf.
case $::operatingsystem {
case $::os['name'] {
/^(RedHat|CentOS|OEL|OracleLinux|SLC|Scientific)$/: {
case $::operatingsystemrelease {
/^[45]/: {
case $::os['release']['major'] {
/^[45]$/: {
augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
changes => [
Expand All @@ -87,7 +78,7 @@
}
}
'Fedora': {
case $::operatingsystemrelease {
case $::os['release']['major'] {
/^(1|2|3|4|5|6|7|8|9|10|11)$/: {
augeas { "modprobe.conf_${title}":
context => '/files/etc/modprobe.conf',
Expand Down
Loading