Skip to content

Commit 540f777

Browse files
author
Jan Kapellen
committed
Fixes #104 vlan in device config
1 parent 106d300 commit 540f777

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,21 @@ Static interface routes (host route):
247247

248248
Normal interface - VLAN - no IP:
249249

250-
class { 'network::global':
251-
vlan => 'yes',
252-
}
253-
254250
network::if { 'eth0.330':
255251
ensure => 'up',
256-
}
252+
vlan => 'yes',
253+
}
257254

258255
Normal interface - VLAN - static IPv4:
259256

260-
class { 'network::global':
261-
vlan => 'yes',
262-
}
263-
264257
network::if::static { 'eth0.330':
265258
ensure => 'up',
266259
ipaddress => '10.2.3.248',
267260
netmask => '255.255.255.0',
261+
vlan => 'yes',
268262
}
269263

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

339333
Issues

manifests/global.pp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# $ipv6defaultdev - optional - Determines the device to use as the default gateway
2121
# for IPV6 traffic.
2222
# $nisdomain - optional - Configures the NIS domainname.
23-
# $vlan - optional - yes|no to enable VLAN kernel module
23+
# $vlan - optional - 'yes' or 'no' [deprecated] use on device level
2424
# $ipv6networking - optional - enables / disables IPv6 globally
2525
# $nozeroconf - optional
2626
# $restart - optional - defaults to true
@@ -43,7 +43,6 @@
4343
# ipv6gateway => '123:4567:89ab:cdef:123:4567:89ab:1',
4444
# ipv6defaultdev => 'eth0',
4545
# nisdomain => 'domain.tld',
46-
# vlan => 'yes',
4746
# ipv6networking => true,
4847
# nozeroconf => 'yes',
4948
# requestreopen => false,
@@ -65,10 +64,10 @@
6564
$hostname = undef,
6665
$gateway = undef,
6766
$gatewaydev = undef,
67+
$vlan = undef,
6868
$ipv6gateway = undef,
6969
$ipv6defaultdev = undef,
7070
$nisdomain = undef,
71-
$vlan = undef,
7271
$ipv6networking = false,
7372
$nozeroconf = undef,
7473
$restart = true,

manifests/if/static.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# $defroute - optional
3030
# $restart - optional - defaults to true
3131
# $arpcheck - optional - defaults to true
32+
# $vlan - optional - yes|no defaults to no
3233
#
3334
# === Actions:
3435
#
@@ -82,6 +83,7 @@
8283
$metric = undef,
8384
$restart = true,
8485
$arpcheck = true,
86+
$vlan = undef,
8587
) {
8688
# Validate our data
8789
if $ipaddress {
@@ -119,6 +121,12 @@
119121
validate_bool($flush)
120122
validate_bool($arpcheck)
121123

124+
# Validate our regular expressions
125+
if $vlan {
126+
$states = [ '^yes$', '^no$' ]
127+
validate_re($vlan, $states, '$vlan must be either "yes" or "no".')
128+
}
129+
122130
network_if_base { $title:
123131
ensure => $ensure,
124132
ipv6init => $ipv6init,
@@ -148,5 +156,6 @@
148156
metric => $metric,
149157
restart => $restart,
150158
arpcheck => $arpcheck,
159+
vlan => $vlan,
151160
}
152161
} # define network::if::static

manifests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
# $promisc - optional - defaults to false
8080
# $restart - optional - defaults to true
8181
# $arpcheck - optional - defaults to true
82+
# $vlan - optional - defaults to 'no'
8283
#
8384
# === Actions:
8485
#
@@ -140,6 +141,7 @@
140141
$promisc = false,
141142
$restart = true,
142143
$arpcheck = true,
144+
$vlan = undef,
143145
) {
144146
# Validate our booleans
145147
validate_bool($noaliasrouting)
@@ -158,6 +160,10 @@
158160
# Validate our regular expressions
159161
$states = [ '^up$', '^down$' ]
160162
validate_re($ensure, $states, '$ensure must be either "up" or "down".')
163+
if($vlan) {
164+
$vlanstates = [ '^yes$', '^no$' ]
165+
validate_re($vlan, $vlanstates, '$vlan must be either "yes" or "no".')
166+
}
161167

162168
include '::network'
163169

spec/defines/network_if_static_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
:metric => '10',
170170
:zone => 'trusted',
171171
:arpcheck => false,
172+
:vlan => 'yes',
172173
}
173174
end
174175
let :facts do {
@@ -212,7 +213,8 @@
212213
'DEFROUTE=yes',
213214
'ZONE=trusted',
214215
'METRIC=10',
215-
'ARPCHECK=no',
216+
'ARPCHECK=no',
217+
'VLAN=yes',
216218
'NM_CONTROLLED=no',
217219
])
218220
end
@@ -225,6 +227,7 @@
225227
:ensure => 'up',
226228
:ipaddress => '1.2.3.4',
227229
:netmask => '255.255.255.0',
230+
:vlan => 'yes',
228231
}
229232
end
230233
let :facts do {
@@ -250,6 +253,7 @@
250253
'TYPE=Ethernet',
251254
'IPADDR=1.2.3.4',
252255
'NETMASK=255.255.255.0',
256+
'VLAN=yes',
253257
'NM_CONTROLLED=no',
254258
])
255259
end

templates/ifcfg-eth.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ check_link_down() {
7070
<% end -%>
7171
<% if !@arpcheck %>ARPCHECK=no
7272
<% end -%>
73+
<% if @vlan %>VLAN=<%= @vlan %>
74+
<% end -%>
7375
NM_CONTROLLED=no

0 commit comments

Comments
 (0)