Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DNSStubListenerExtra for resolved.conf #371

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The following parameters are available in the `systemd` class:
* [`dnsovertls`](#-systemd--dnsovertls)
* [`cache`](#-systemd--cache)
* [`dns_stub_listener`](#-systemd--dns_stub_listener)
* [`dns_stub_listener_extra`](#-systemd--dns_stub_listener_extra)
* [`manage_resolv_conf`](#-systemd--manage_resolv_conf)
* [`use_stub_resolver`](#-systemd--use_stub_resolver)
* [`manage_networkd`](#-systemd--manage_networkd)
Expand Down Expand Up @@ -287,6 +288,14 @@ Takes a boolean argument or one of "udp" and "tcp".

Default value: `undef`

##### <a name="-systemd--dns_stub_listener_extra"></a>`dns_stub_listener_extra`

Data type: `Optional[Array[String[1]]]`

Additional addresses for the DNS stub listener to listen on

Default value: `undef`

##### <a name="-systemd--manage_resolv_conf"></a>`manage_resolv_conf`

Data type: `Boolean`
Expand Down
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_extra':
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').with_value(['192.0.2.1', '2001:db8::1']) }
end

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