Skip to content

Commit 368d513

Browse files
committed
Merge pull request #143 from rski/fix_absent_in_redhat_files
Make :absent attributes not get written to redhat files
2 parents 487bc6c + 0015352 commit 368d513

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/puppet/provider/network_config/redhat.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def self.format_file(filename, providers)
184184

185185
# Map everything to a flat hash
186186
NAME_MAPPINGS.keys.each do |type_name|
187-
if (val = provider.send(type_name))
187+
if (val = provider.send(type_name)) && val != :absent
188188
props[type_name] = val
189189
end
190190
end

spec/unit/provider/network_config/redhat_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ def fixture_data(file)
376376
)
377377
end
378378

379+
let(:eth1_provider) do
380+
stub('eth1_provider',
381+
:name => 'eth1',
382+
:ensure => :present,
383+
:onboot => :absent,
384+
:hotplug => true,
385+
:family => 'inet',
386+
:method => 'none',
387+
:ipaddress => :absent,
388+
:netmask => :absent,
389+
:mtu => :absent,
390+
:mode => :vlan,
391+
:options => :absent,
392+
)
393+
end
394+
379395
let(:lo_provider) do
380396
stub('lo_provider',
381397
:name => 'lo',
@@ -439,6 +455,14 @@ def fixture_data(file)
439455
it { expect(data).to match(/VLAN=yes/) }
440456
end
441457

458+
describe 'with test interface eth1' do
459+
let(:data) { described_class.format_file('filepath', [eth1_provider]) }
460+
461+
it { expect(data).to match(/DEVICE=eth1/) }
462+
it { expect(data).to match(/VLAN=yes/) }
463+
it { expect(data).to_not match(/absent/) }
464+
end
465+
442466
describe 'with test interface bond0' do
443467
let(:data) { described_class.format_file('filepath', [bond0_provider]) }
444468

0 commit comments

Comments
 (0)