Skip to content

Commit

Permalink
Implement DNSStubListenerExtra for resolved.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Aug 5, 2023
1 parent 21a0285 commit b77d490
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param dns_stub_listener_extra
# Additional addresses for the DNS stub listener to listen on
#
# @param manage_resolv_conf
# For when `manage_resolved` is `true` should the file `/etc/resolv.conf` be managed.
#
Expand Down Expand Up @@ -197,6 +200,7 @@
Variant[Boolean,Enum['yes', 'opportunistic', 'no']] $dnsovertls = false,
Variant[Boolean,Enum['no-negative']] $cache = false,
Optional[Variant[Boolean,Enum['udp','tcp']]] $dns_stub_listener = undef,
Optional[Array[String[1]]] $dns_stub_listener_extra = undef,
Boolean $manage_resolv_conf = true,
Boolean $use_stub_resolver = false,
Boolean $manage_networkd = false,
Expand Down
15 changes: 15 additions & 0 deletions manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param dns_stub_listener_extra
# Additional addresses for the DNS stub listener to listen on
#
# @param use_stub_resolver
# Takes a boolean argument. When "false" (default) it uses /run/systemd/resolve/resolv.conf
# as /etc/resolv.conf. When "true", it uses /run/systemd/resolve/stub-resolv.conf
Expand All @@ -56,6 +59,7 @@
Optional[Variant[Boolean,Enum['yes', 'opportunistic', 'no']]] $dnsovertls = $systemd::dnsovertls,
Optional[Variant[Boolean,Enum['no-negative']]] $cache = $systemd::cache,
Optional[Variant[Boolean,Enum['udp', 'tcp']]] $dns_stub_listener = $systemd::dns_stub_listener,
Optional[Array[String[1]]] $dns_stub_listener_extra = $systemd::dns_stub_listener_extra,
Boolean $use_stub_resolver = $systemd::use_stub_resolver,
) {
assert_private()
Expand Down Expand Up @@ -245,4 +249,15 @@
notify => Service['systemd-resolved'],
}
}

if $dns_stub_listener_extra {
ini_setting { 'dns_stub_listener':
ensure => 'present',
value => $dns_stub_listener_extra,
setting => 'DNSStubListenerExtra',
section => 'Resolve',
path => '/etc/systemd/resolved.conf',
notify => Service['systemd-resolved'],
}
}
}
2 changes: 2 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
dnsovertls: 'no',
cache: true,
dns_stub_listener: 'udp',
dns_stub_listener_extra: ['192.0.2.1', '2001:db8::1'],
}
end

Expand All @@ -164,6 +165,7 @@
}

it { is_expected.to contain_ini_setting('dns_stub_listener') }
it { is_expected.to contain_ini_setting('dns_stub_listener_extra') }
end

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

0 comments on commit b77d490

Please sign in to comment.