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

Added support for policy based routing and RHEL8 #155

Open
wants to merge 3 commits 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
7 changes: 6 additions & 1 deletion manifests/alias/range.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
'absent' => 'absent',
default => undef,
}
if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

file { "ifcfg-${interface}-range${clonenum_start}":
ensure => $file_ensure,
Expand All @@ -88,7 +93,7 @@

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

Expand Down
9 changes: 7 additions & 2 deletions manifests/bond/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# === Requires:
#
# Service['network']
# Class['network::service']
#
# === Sample Usage:
#
Expand Down Expand Up @@ -61,6 +61,11 @@
include '::network'

$interface = $name
if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

file { "ifcfg-${interface}":
ensure => 'present',
Expand All @@ -74,7 +79,7 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # define network::bond::slave
7 changes: 6 additions & 1 deletion manifests/bridge.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
'down' => 'no',
default => undef,
}
if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

file { "ifcfg-${interface}":
ensure => 'present',
Expand All @@ -80,7 +85,7 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # define network::bridge
7 changes: 6 additions & 1 deletion manifests/bridge/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
'down' => 'no',
default => undef,
}
if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

file { "ifcfg-${interface}":
ensure => 'present',
Expand All @@ -81,7 +86,7 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # define network::bridge::dynamic
7 changes: 6 additions & 1 deletion manifests/bridge/static.pp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
'down' => 'no',
default => undef,
}
if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

file { "ifcfg-${interface}":
ensure => 'present',
Expand All @@ -125,7 +130,7 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # define network::bridge::static
4 changes: 2 additions & 2 deletions manifests/global.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#
# === Requires:
#
# Service['network']
# Class['network::service']
#
# === Sample Usage:
#
Expand Down Expand Up @@ -129,7 +129,7 @@

if $restart {
File['network.sysconfig'] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # class global
2 changes: 1 addition & 1 deletion manifests/hiera.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# === Requires:
#
# Service['network']
# Class['network::service']
#
# === Sample Usage:
#
Expand Down
2 changes: 1 addition & 1 deletion manifests/if/promisc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# === Requires:
#
# Service['network']
# Class['network::service']
#
# === Sample Usage:
#
Expand Down
21 changes: 10 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# === Actions:
#
# Defines the network service so that other resources can notify it to restart.
# Fails if not on a RHEL system
#
# === Sample Usage:
#
Expand All @@ -30,14 +30,7 @@
fail('This network module only supports RedHat-based systems.')
}
}

service { 'network':
ensure => 'running',
enable => true,
hasrestart => true,
hasstatus => true,
provider => 'redhat',
}
contain network::service
} # class network

# == Definition: network_if_base
Expand Down Expand Up @@ -177,6 +170,12 @@
$dns2_real = $dns2
}

if versioncmp($::operatingsystemrelease, '8') >= 0 {
$nm_controlled = true
} else {
$nm_controlled = false
}

if $isalias {
$onparent = $ensure ? {
'up' => 'yes',
Expand All @@ -199,7 +198,7 @@
command => "ip addr flush dev ${interface}",
refreshonly => true,
subscribe => File["ifcfg-${interface}"],
before => Service['network'],
before => Class['network::service'],
path => '/sbin:/usr/sbin',
}
}
Expand All @@ -215,7 +214,7 @@

if $restart {
File["ifcfg-${interface}"] {
notify => Service['network'],
notify => Class['network::service'],
}
}
} # define network_if_base
Expand Down
64 changes: 48 additions & 16 deletions manifests/route.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# === Requires:
#
# File["ifcfg-$name"]
# Service['network']
# Class['network::service']
#
# === Sample Usage:
#
Expand All @@ -41,35 +41,67 @@
# Copyright (C) 2011 Mike Arnold, unless otherwise noted.
#
define network::route (
$ipaddress,
$netmask,
$gateway,
$restart = true,
$ipaddress = [],
$netmask = [],
$gateway = [],
$ipv4_routes = [],
$ipv6_routes = [],
$restart = true,
) {
# Validate our arrays
validate_array($ipaddress)
validate_array($netmask)
validate_array($gateway)
validate_array($ipv4_routes)
validate_array($ipv6_routes)
# Validate our booleans
validate_bool($restart)

include '::network'

$interface = $name

file { "route-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/route-${interface}",
content => template('network/route-eth.erb'),
before => File["ifcfg-${interface}"],
if $restart {
$notify = Class['network::service']
} else {
$notify = undef
}

if $restart {
File["route-${interface}"] {
notify => Service['network'],
if empty($ipaddress) and (!empty($ipv4_routes) or !empty($ipv6_routes)) {
if ! empty($ipv4_routes) {
file { "route-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/route-${interface}",
content => template('network/route-eth-v4.erb'),
before => File["ifcfg-${interface}"],
notify => $notify,
}
}
if ! empty($ipv6_routes) {
file { "route6-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/route6-${interface}",
content => template('network/route-eth-v6.erb'),
before => File["ifcfg-${interface}"],
notify => $notify,
}
}
} else {
file { "route-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/route-${interface}",
content => template('network/route-eth.erb'),
before => File["ifcfg-${interface}"],
notify => $notify,
}
}
} # define network::route
84 changes: 84 additions & 0 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# == Definition: network::rule
#
# Configures /etc/sysconfig/networking-scripts/rule-$name.
#
# === Parameters:
#
# $ipv4_rules
# $ipv6_rules
#
# === Actions:
#
# Deploys the file /etc/sysconfig/network-scripts/rule-$name.
#
# === Requires:
#
# File["ifcfg-$name"]
# Class['network::service']
#
# === Sample Usage:
#
# network::route { 'eth0':
# ipv4_rules => [{
# iif => 'eth0',
# table => 1,
# },{
# from => '192.168.200.100',
# table => 1,
# },]
# }
#
# === Authors:
#
# Manfred Pusch <[email protected]>
#
# === Copyright:
#
# Copyright (C) 2016 Manfred Pusch, unless otherwise noted.
#
define network::rule (
$ipv4_rules = [],
$ipv6_rules = [],
$restart = true,
) {
# Validate our arrays
validate_array($ipv4_rules)
validate_array($ipv6_rules)
# Validate our booleans
validate_bool($restart)

include '::network'

$interface = $name

if $restart {
$notify = Class['network::service']
} else {
$notify = undef
}

if ! empty($ipv4_rules) {
file { "rule-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/rule-${interface}",
content => template('network/rule-eth-v4.erb'),
before => File["ifcfg-${interface}"],
notify => $notify,
}
}
if ! empty($ipv6_rules) {
file { "rule6-${interface}":
ensure => 'present',
mode => '0644',
owner => 'root',
group => 'root',
path => "/etc/sysconfig/network-scripts/rule6-${interface}",
content => template('network/rule-eth-v6.erb'),
before => File["ifcfg-${interface}"],
notify => $notify,
}
}
} # define network::rule
Loading