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

Fixes #104 vlan in device config #138

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
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,21 @@ Static interface routes (host route):

Normal interface - VLAN - no IP:

class { 'network::global':
vlan => 'yes',
}

network::if { 'eth0.330':
ensure => 'up',
}
vlan => 'yes',
}

Normal interface - VLAN - static IPv4:

class { 'network::global':
vlan => 'yes',
}

network::if::static { 'eth0.330':
ensure => 'up',
ipaddress => '10.2.3.248',
netmask => '255.255.255.0',
vlan => 'yes',
}


Promiscuous interface:
To set a static or dynamic interface to promiscuous mode (RedHat only), add:
promisc => true
Expand Down Expand Up @@ -333,7 +328,6 @@ Notes
* It is assumed that if you create a bond that you also create the slave interface(s).
* It is assumed that if you create an alias that you also create the parent interface.
* network::route requires the referenced device to also be defined via network::if or network::bond.
* For VLANs to work, `Class['network::global']` must have parameter `vlan` set to `yes`.
* To enable IPv6 you have to set both `ipv6networking` in `Class['network::global']` to `true` and `ipv6init` in `network::if::static` to `true`.

Issues
Expand Down
5 changes: 2 additions & 3 deletions manifests/global.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# $ipv6defaultdev - optional - Determines the device to use as the default gateway
# for IPV6 traffic.
# $nisdomain - optional - Configures the NIS domainname.
# $vlan - optional - yes|no to enable VLAN kernel module
# $vlan - optional - yes|no [deprecated] use on device level
# $ipv6networking - optional - enables / disables IPv6 globally
# $nozeroconf - optional
# $restart - optional - defaults to true
Expand All @@ -43,7 +43,6 @@
# ipv6gateway => '123:4567:89ab:cdef:123:4567:89ab:1',
# ipv6defaultdev => 'eth0',
# nisdomain => 'domain.tld',
# vlan => 'yes',
# ipv6networking => true,
# nozeroconf => 'yes',
# requestreopen => false,
Expand All @@ -65,10 +64,10 @@
$hostname = undef,
$gateway = undef,
$gatewaydev = undef,
$vlan = undef,
$ipv6gateway = undef,
$ipv6defaultdev = undef,
$nisdomain = undef,
$vlan = undef,
$ipv6networking = false,
$nozeroconf = undef,
$restart = true,
Expand Down
9 changes: 9 additions & 0 deletions manifests/if/static.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# $defroute - optional
# $restart - optional - defaults to true
# $arpcheck - optional - defaults to true
# $vlan - optional - yes|no defaults to no
#
# === Actions:
#
Expand Down Expand Up @@ -82,6 +83,7 @@
$metric = undef,
$restart = true,
$arpcheck = true,
$vlan = undef,
) {
# Validate our data
if $ipaddress {
Expand Down Expand Up @@ -119,6 +121,12 @@
validate_bool($flush)
validate_bool($arpcheck)

# Validate our regular expressions
if $vlan {
$states = [ '^yes$', '^no$' ]
validate_re($vlan, $states, '$vlan must be either "yes" or "no".')
}

network_if_base { $title:
ensure => $ensure,
ipv6init => $ipv6init,
Expand Down Expand Up @@ -148,5 +156,6 @@
metric => $metric,
restart => $restart,
arpcheck => $arpcheck,
vlan => $vlan,
}
} # define network::if::static
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
# $promisc - optional - defaults to false
# $restart - optional - defaults to true
# $arpcheck - optional - defaults to true
# $vlan - optional - defaults to 'no'
#
# === Actions:
#
Expand Down Expand Up @@ -140,6 +141,7 @@
$promisc = false,
$restart = true,
$arpcheck = true,
$vlan = undef,
) {
# Validate our booleans
validate_bool($noaliasrouting)
Expand All @@ -158,6 +160,10 @@
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')
if($vlan) {
$vlanstates = [ '^yes$', '^no$' ]
validate_re($vlan, $vlanstates, '$vlan must be either "yes" or "no".')
}

include '::network'

Expand Down
6 changes: 5 additions & 1 deletion spec/defines/network_if_static_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
:metric => '10',
:zone => 'trusted',
:arpcheck => false,
:vlan => 'yes',
}
end
let :facts do {
Expand Down Expand Up @@ -212,7 +213,8 @@
'DEFROUTE=yes',
'ZONE=trusted',
'METRIC=10',
'ARPCHECK=no',
'ARPCHECK=no',
'VLAN=yes',
'NM_CONTROLLED=no',
])
end
Expand All @@ -225,6 +227,7 @@
:ensure => 'up',
:ipaddress => '1.2.3.4',
:netmask => '255.255.255.0',
:vlan => 'yes',
}
end
let :facts do {
Expand All @@ -250,6 +253,7 @@
'TYPE=Ethernet',
'IPADDR=1.2.3.4',
'NETMASK=255.255.255.0',
'VLAN=yes',
'NM_CONTROLLED=no',
])
end
Expand Down
2 changes: 2 additions & 0 deletions templates/ifcfg-eth.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ check_link_down() {
<% end -%>
<% if !@arpcheck %>ARPCHECK=no
<% end -%>
<% if @vlan %>VLAN=<%= @vlan %>
<% end -%>
NM_CONTROLLED=no