Skip to content

Commit

Permalink
remove resovled settings from config when changed to undef
Browse files Browse the repository at this point in the history
fixes #397
  • Loading branch information
TheMeier committed Mar 9, 2024
1 parent 5031e05 commit 08c6bfb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
32 changes: 14 additions & 18 deletions manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,21 @@
default => $dns_stub_listener,
}

if $_dns_stub_listener {
ini_setting { 'dns_stub_listener':
ensure => 'present',
value => $_dns_stub_listener,
setting => 'DNSStubListener',
section => 'Resolve',
path => '/etc/systemd/resolved.conf',
notify => Service['systemd-resolved'],
}
ini_setting { 'dns_stub_listener':
ensure => stdlib::ensure($_dns_stub_listener != undef),
value => $_dns_stub_listener,
setting => 'DNSStubListener',
section => 'Resolve',
path => '/etc/systemd/resolved.conf',
notify => Service['systemd-resolved'],
}

if $dns_stub_listener_extra {
ini_setting { 'dns_stub_listener_extra':
ensure => 'present',
value => $dns_stub_listener_extra,
setting => 'DNSStubListenerExtra',
section => 'Resolve',
path => '/etc/systemd/resolved.conf',
notify => Service['systemd-resolved'],
}
ini_setting { 'dns_stub_listener_extra':
ensure => stdlib::ensure($dns_stub_listener_extra != undef),
value => $dns_stub_listener_extra,
setting => 'DNSStubListenerExtra',
section => 'Resolve',
path => '/etc/systemd/resolved.conf',
notify => Service['systemd-resolved'],
}
}
13 changes: 9 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
it { is_expected.not_to contain_ini_setting('dnssec') }
it { is_expected.not_to contain_ini_setting('dnsovertls') }
it { is_expected.not_to contain_ini_setting('cache') }
it { is_expected.not_to contain_ini_setting('dns_stub_listener') }
it { is_expected.to contain_ini_setting('dns_stub_listener').with_ensure('absent') }
end

context 'when enabling resolved with DNS values (array)' do
Expand All @@ -134,7 +134,7 @@
it { is_expected.not_to contain_ini_setting('dnssec') }
it { is_expected.not_to contain_ini_setting('dnsovertls') }
it { is_expected.not_to contain_ini_setting('cache') }
it { is_expected.not_to contain_ini_setting('dns_stub_listener') }
it { is_expected.to contain_ini_setting('dns_stub_listener').with_ensure('absent') }
end

context 'when enabling resolved with DNS values (full)' do
Expand Down Expand Up @@ -171,8 +171,13 @@
)
}

it { is_expected.to contain_ini_setting('dns_stub_listener') }
it { is_expected.to contain_ini_setting('dns_stub_listener_extra').with_value(['192.0.2.1', '2001:db8::1']) }
it { is_expected.to contain_ini_setting('dns_stub_listener').with_ensure('present') }

it {
is_expected.to contain_ini_setting('dns_stub_listener_extra').
with_value(['192.0.2.1', '2001:db8::1']).
with_ensure('present')
}
end

context 'when enabling resolved with no-negative cache variant' do
Expand Down

0 comments on commit 08c6bfb

Please sign in to comment.