File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,15 @@ Normal interface - dhcp:
107
107
ethtool_opts => 'autoneg off speed 100 duplex full',
108
108
}
109
109
110
+ Normal interface - dhcp with custom DNS servers (peerdns must be true):
111
+
112
+ network::if::dynamic { 'eth0':
113
+ ensure => 'up',
114
+ peerdns => true,
115
+ dns1 => '8.8.8.8',
116
+ dns2 => '8.8.4.4',
117
+ }
118
+
110
119
Normal interface - bootp (minimal):
111
120
112
121
network::if::dynamic { 'eth2':
Original file line number Diff line number Diff line change 13
13
# $dhcp_hostname - optional
14
14
# $ethtool_opts - optional
15
15
# $peerdns - optional
16
+ # $dns1 - optional - only used when peerdns is true
17
+ # $dns2 - optional - only used when peerdns is true
16
18
# $linkdelay - optional
17
19
# $check_link_down - optional
18
20
# $zone - optional
55
57
$dhcp_hostname = undef ,
56
58
$ethtool_opts = undef ,
57
59
$peerdns = false ,
60
+ $dns1 = undef ,
61
+ $dns2 = undef ,
58
62
$linkdelay = undef ,
59
63
$check_link_down = false ,
60
64
$defroute = undef ,
78
82
validate_bool($peerdns )
79
83
validate_bool($manage_hwaddr )
80
84
85
+ if !$peerdns and ($dns1 or $dns2 ) {
86
+ fail(' $peerdns must be true when $dns1 or $dns2 are specified' )
87
+ }
88
+
81
89
network_if_base { $title:
82
90
ensure => $ensure ,
83
91
ipaddress => ' ' ,
91
99
dhcp_hostname => $dhcp_hostname ,
92
100
ethtool_opts => $ethtool_opts ,
93
101
peerdns => $peerdns ,
102
+ dns1 => $dns1 ,
103
+ dns2 => $dns2 ,
94
104
linkdelay => $linkdelay ,
95
105
check_link_down => $check_link_down ,
96
106
defroute => $defroute ,
Original file line number Diff line number Diff line change 164
164
it { should contain_service ( 'network' ) }
165
165
end
166
166
167
+ context 'optional parameters - static dns' do
168
+ let ( :title ) { 'eth0' }
169
+ let :params do {
170
+ :ensure => 'up' ,
171
+ :peerdns => true ,
172
+ :dns1 => '8.8.8.8' ,
173
+ :dns2 => '8.8.4.4' ,
174
+ :macaddress_eth0 => 'bb:cc:bb:cc:bb:cc'
175
+ }
176
+ end
177
+ let :facts do {
178
+ :osfamily => 'RedHat'
179
+ }
180
+ end
181
+ it { should contain_file ( 'ifcfg-eth0' ) . with (
182
+ :ensure => 'present' ,
183
+ :mode => '0644' ,
184
+ :owner => 'root' ,
185
+ :group => 'root' ,
186
+ :path => '/etc/sysconfig/network-scripts/ifcfg-eth0' ,
187
+ :notify => 'Service[network]'
188
+ ) }
189
+ it 'should contain File[ifcfg-eth0] with required contents' do
190
+ verify_contents ( catalogue , 'ifcfg-eth0' , [
191
+ 'DEVICE=eth0' ,
192
+ 'PEERDNS=yes' ,
193
+ 'DNS1=8.8.8.8' ,
194
+ 'DNS2=8.8.4.4' ,
195
+ 'HWADDR=bb:cc:bb:cc:bb:cc'
196
+ ] )
197
+ end
198
+ it { should contain_service ( 'network' ) }
199
+ end
167
200
168
201
end
You can’t perform that action at this time.
0 commit comments