Skip to content

Ensure NSS libraries are installed when managing systemd-resolved on Debian family #527

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

Merged
merged 3 commits into from
Mar 25, 2025
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 @@ -115,6 +115,7 @@ The following parameters are available in the `systemd` class:
* [`manage_resolved`](#-systemd--manage_resolved)
* [`resolved_ensure`](#-systemd--resolved_ensure)
* [`resolved_package`](#-systemd--resolved_package)
* [`resolved_libraries`](#-systemd--resolved_libraries)
* [`manage_nspawn`](#-systemd--manage_nspawn)
* [`nspawn_package`](#-systemd--nspawn_package)
* [`dns`](#-systemd--dns)
Expand Down Expand Up @@ -253,6 +254,14 @@ The name of a systemd sub package needed for systemd-resolved if one needs to be

Default value: `undef`

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

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

List of library packages needed for systemd-resolved.

Default value: `[]`

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

Data type: `Boolean`
Expand Down
4 changes: 4 additions & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
systemd::nspawn_package: 'systemd-container'
systemd::journal_upload::package_name: 'systemd-journal-remote'
systemd::journal_remote::package_name: 'systemd-journal-remote'
systemd::resolved_libraries:
- libnss-myhostname
- libnss-resolve
- libnss-systemd
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
# @param resolved_package
# The name of a systemd sub package needed for systemd-resolved if one needs to be installed.
#
# @param resolved_libraries
# List of library packages needed for systemd-resolved.
#
# @param manage_nspawn
# Manage the systemd-nspawn@service and machinectl subsystem.
#
Expand Down Expand Up @@ -260,6 +263,7 @@
Stdlib::CreateResources $unit_files = {},
Boolean $manage_resolved = false,
Optional[Enum['systemd-resolved']] $resolved_package = undef,
Array[String[1]] $resolved_libraries = [],
Enum['stopped','running'] $resolved_ensure = 'running',
Optional[Variant[Array[String],String]] $dns = undef,
Optional[Variant[Array[String],String]] $fallback_dns = undef,
Expand Down
14 changes: 11 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@
}
}

if $systemd::manage_resolved and $systemd::resolved_package {
package { $systemd::resolved_package:
ensure => present,
if $systemd::manage_resolved {
if $systemd::resolved_package {
package { $systemd::resolved_package:
ensure => installed,
}
}

$systemd::resolved_libraries.each |String[1] $pkg| {
package { $pkg:
ensure => installed,
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions spec/acceptance/resolved_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
end

it { expect(package('systemd-resolved')).to be_installed } if has_package

if fact('os.family') == 'Debian'
%w[
myhostname
resolve
systemd
].each do |pkg|
it { expect(package("libnss-#{pkg}")).to be_installed }
end
end
end

context 'configure systemd stopped' do
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@
else
it { is_expected.not_to contain_package('systemd-resolved') }
end

if facts[:os]['family'] == 'Debian'
%w[
myhostname
resolve
systemd
].each do |pkg|
it { is_expected.to contain_package("libnss-#{pkg}") }
end
end

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

Expand Down