Skip to content

Commit

Permalink
Merge pull request #256 from traylenator/skip
Browse files Browse the repository at this point in the history
New parmater manage_resolv_conf for /etc/resolv.conf
  • Loading branch information
ekohl authored Feb 21, 2022
2 parents 8021d9f + 299c6d6 commit a291dd9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
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

0 comments on commit a291dd9

Please sign in to comment.