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

New parmater manage_resolv_conf for /etc/resolv.conf #256

Merged
merged 1 commit into from
Feb 21, 2022
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
11 changes: 10 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The following parameters are available in the `systemd` class:
* [`dnsovertls`](#dnsovertls)
* [`cache`](#cache)
* [`dns_stub_listener`](#dns_stub_listener)
* [`manage_resolv_conf`](#manage_resolv_conf)
* [`use_stub_resolver`](#use_stub_resolver)
* [`manage_networkd`](#manage_networkd)
* [`networkd_ensure`](#networkd_ensure)
Expand Down Expand Up @@ -255,6 +256,14 @@ Takes a boolean argument or one of "udp" and "tcp".

Default value: ``undef``

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

Data type: `Boolean`

For when `manage_resolved` is `true` should the file `/etc/resolv.conf` be managed.

Default value: ``true``

##### <a name="use_stub_resolver"></a>`use_stub_resolver`

Data type: `Boolean`
Expand Down Expand Up @@ -489,7 +498,7 @@ Default value: `{}`

Data type: `Boolean`

Add --backtrace to systemd-coredump call in the kernel.core_pattern setting.
Add --backtrace to systemd-coredump call systemd-coredump@.service unit

Default value: ``false``

Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param manage_resolv_conf
# For when `manage_resolved` is `true` should the file `/etc/resolv.conf` be managed.
#
# @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 Down Expand Up @@ -171,6 +174,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,
Boolean $manage_resolv_conf = true,
Boolean $use_stub_resolver = false,
Boolean $manage_networkd = false,
Enum['stopped','running'] $networkd_ensure = 'running',
Expand Down
18 changes: 10 additions & 8 deletions manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@
enable => $_enable_resolved,
}

$_resolv_conf_target = $use_stub_resolver ? {
true => '/run/systemd/resolve/stub-resolv.conf',
default => '/run/systemd/resolve/resolv.conf',
}
file { '/etc/resolv.conf':
ensure => 'symlink',
target => $_resolv_conf_target,
require => Service['systemd-resolved'],
if $systemd::manage_resolv_conf {
$_resolv_conf_target = $use_stub_resolver ? {
true => '/run/systemd/resolve/stub-resolv.conf',
default => '/run/systemd/resolve/resolv.conf',
}
file { '/etc/resolv.conf':
ensure => 'symlink',
target => $_resolv_conf_target,
require => Service['systemd-resolved'],
}
}

if $dns {
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

it { is_expected.to create_service('systemd-resolved').with_ensure('running') }
it { is_expected.to create_service('systemd-resolved').with_enable(true) }
it { is_expected.to contain_file('/etc/resolv.conf') }
it { is_expected.to create_service('systemd-networkd').with_ensure('running') }
it { is_expected.to create_service('systemd-networkd').with_enable(true) }
it { is_expected.not_to contain_file('/etc/systemd/network') }
Expand All @@ -39,6 +40,17 @@
else
it { is_expected.not_to contain_package('systemd-resolved') }
end
context 'with manage_resolv_conf false' do
let(:params) { super().merge(manage_resolv_conf: false) }

it { is_expected.not_to contain_file('/etc/resolv.conf') }
end

context 'with manage_resolv_conf true' do
let(:params) { super().merge(manage_resolv_conf: true) }

it { is_expected.to contain_file('/etc/resolv.conf') }
end
end

context 'when enabling resolved with DNS values (string)' do
Expand Down