forked from razorsedge/puppet-network
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix both razorsedge#134 and razorsedge#135
- Loading branch information
Edwin Wiles
committed
Oct 22, 2017
1 parent
c44cee2
commit 7fc0303
Showing
2 changed files
with
32 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,13 @@ | |
# gateway => [ '192.168.1.1', '10.0.0.1', ], | ||
# } | ||
# | ||
# network::route { 'ens192': | ||
# ipaddress => [ | ||
# '192.168.2.0/24 via 192.168.1.1', | ||
# '10.0.0.0/8 via 10.0.0.1' | ||
# ] | ||
# } | ||
# | ||
# === Authors: | ||
# | ||
# Mike Arnold <[email protected]> | ||
|
@@ -41,29 +48,37 @@ | |
# Copyright (C) 2011 Mike Arnold, unless otherwise noted. | ||
# | ||
define network::route ( | ||
$ipaddress, | ||
$netmask, | ||
$gateway, | ||
$restart = true, | ||
Array[String] $ipaddress, | ||
Optional[Array[String]] $netmask = undef, | ||
Optional[Array[String]] $gateway = undef, | ||
Boolean $restart = true, | ||
) { | ||
# Validate our arrays | ||
validate_array($ipaddress) | ||
validate_array($netmask) | ||
validate_array($gateway) | ||
# Validate our booleans | ||
validate_bool($restart) | ||
|
||
include '::network' | ||
|
||
$interface = $name | ||
|
||
if $ipaddress != undef and $netmask != undef and $gateway != undef { | ||
if length($ipaddress) == length($netmask) and length($netmask) == length($gateway) { | ||
$template = 'network/route-eth.erb'; | ||
else { | ||
fail { 'All arrays must be the same length': } | ||
} | ||
} | ||
elsif $netmask == undef and $gateway == undef { | ||
$template = 'network/route-eth-ip.erb'; | ||
} | ||
else { | ||
fail { 'Either use just ipaddress, or use all three array parameters': } | ||
} | ||
|
||
file { "route-${interface}": | ||
ensure => 'present', | ||
mode => '0644', | ||
owner => 'root', | ||
group => 'root', | ||
path => "/etc/sysconfig/network-scripts/route-${interface}", | ||
content => template('network/route-eth.erb'), | ||
content => template($template), | ||
before => File["ifcfg-${interface}"], | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### | ||
### File managed by Puppet | ||
### | ||
<% @ipaddress.each do |addr| -%> | ||
<%= addr %> | ||
<% end -%> |