diff --git a/REFERENCE.md b/REFERENCE.md
index 495dcb32..c8688434 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -60,6 +60,10 @@ This module allows triggering systemd commands once for all modules
The following parameters are available in the `systemd` class:
* [`service_limits`](#service_limits)
+* [`networks`](#networks)
+* [`timers`](#timers)
+* [`tmpfiles`](#tmpfiles)
+* [`unit_files`](#unit_files)
* [`manage_resolved`](#manage_resolved)
* [`resolved_ensure`](#resolved_ensure)
* [`dns`](#dns)
@@ -100,13 +104,45 @@ The following parameters are available in the `systemd` class:
##### `service_limits`
-Data type: `Hash[String,Hash[String, Any]]`
+Data type: `Hash[String[1],Hash[String[1], Any]]`
May be passed a resource hash suitable for passing directly into the
``create_resources()`` function as called on ``systemd::service_limits``
Default value: `{}`
+##### `networks`
+
+Data type: `Hash[String[1],Hash[String[1], Any]]`
+
+Hash of `systemd::network` resources
+
+Default value: `{}`
+
+##### `timers`
+
+Data type: `Hash[String[1],Hash[String[1], Any]]`
+
+Hash of `systemd::timer` resources
+
+Default value: `{}`
+
+##### `tmpfiles`
+
+Data type: `Hash[String[1],Hash[String[1], Any]]`
+
+Hash of `systemd::tmpfile` resources
+
+Default value: `{}`
+
+##### `unit_files`
+
+Data type: `Hash[String[1],Hash[String[1], Any]]`
+
+Hash of `systemd::unit_file` resources
+
+Default value: `{}`
+
##### `manage_resolved`
Data type: `Boolean`
diff --git a/manifests/init.pp b/manifests/init.pp
index 22fb6f49..0ef3ab3e 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -6,6 +6,18 @@
# May be passed a resource hash suitable for passing directly into the
# ``create_resources()`` function as called on ``systemd::service_limits``
#
+# @param networks
+# Hash of `systemd::network` resources
+#
+# @param timers
+# Hash of `systemd::timer` resources
+#
+# @param tmpfiles
+# Hash of `systemd::tmpfile` resources
+#
+# @param unit_files
+# Hash of `systemd::unit_file` resources
+#
# @param manage_resolved
# Manage the systemd resolver
#
@@ -130,7 +142,11 @@
#
class systemd (
Hash[String,String] $accounting,
- Hash[String,Hash[String, Any]] $service_limits = {},
+ Hash[String[1],Hash[String[1], Any]] $service_limits = {},
+ Hash[String[1],Hash[String[1], Any]] $networks = {},
+ Hash[String[1],Hash[String[1], Any]] $timers = {},
+ Hash[String[1],Hash[String[1], Any]] $tmpfiles = {},
+ Hash[String[1],Hash[String[1], Any]] $unit_files = {},
Boolean $manage_resolved = false,
Enum['stopped','running'] $resolved_ensure = 'running',
Optional[Variant[Array[String],String]] $dns = undef,
@@ -168,7 +184,31 @@
Hash $dropin_files = {},
Hash $udev_rules = {},
) {
- create_resources('systemd::service_limits', $service_limits)
+ $service_limits.each |$service_limit, $service_limit_data| {
+ systemd::service_limits { $service_limit:
+ * => $service_limit_data,
+ }
+ }
+ $networks.each |$network, $network_data| {
+ systemd::network { $network:
+ * => $network_data,
+ }
+ }
+ $timers.each |$timer, $timer_data| {
+ systemd::timer { $timer:
+ * => $timer_data,
+ }
+ }
+ $tmpfiles.each |$tmpfile, $tmpfile_data| {
+ systemd::tmpfile { $tmpfile:
+ * => $tmpfile_data,
+ }
+ }
+ $unit_files.each |$unit_file, $unit_file_data| {
+ systemd::unit_file { $unit_file:
+ * => $unit_file_data,
+ }
+ }
if $manage_resolved and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-resolved.service'] {
contain systemd::resolved
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 0f18fac8..54466a94 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -179,7 +179,65 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__service_limits('openstack-nova-compute.service').with_limits('LimitNOFILE' => 32_768) }
end
+ context 'when passing networks' do
+ let :params do
+ {
+ networks: { 'uplink.network' => { 'content' => 'foo' }, 'uplink.netdev' => { 'content' => 'bar' }, },
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_systemd__network('uplink.network').with_content('foo') }
+ it { is_expected.to contain_systemd__network('uplink.netdev').with_content('bar') }
+ it { is_expected.to contain_file('/etc/systemd/network/uplink.network') }
+ it { is_expected.to contain_file('/etc/systemd/network/uplink.netdev') }
+ it { is_expected.to have_systemd__network_resource_count(2) }
+ end
+ context 'when passing timers' do
+ let :params do
+ {
+ timers: { 'first.timer' => { 'timer_content' => 'foo' }, 'second.timer' => { 'timer_content' => 'bar' }, },
+ }
+ end
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_systemd__timer('first.timer').with_timer_content('foo') }
+ it { is_expected.to contain_systemd__timer('second.timer').with_timer_content('bar') }
+ it { is_expected.to contain_systemd__unit_file('first.timer').with_content('foo') }
+ it { is_expected.to contain_systemd__unit_file('second.timer').with_content('bar') }
+ it { is_expected.to contain_file('/etc/systemd/system/first.timer') }
+ it { is_expected.to contain_file('/etc/systemd/system/second.timer') }
+ it { is_expected.to have_systemd__timer_resource_count(2) }
+ it { is_expected.to have_systemd__unit_file_resource_count(2) }
+ end
+ context 'when passing tmpfiles' do
+ let :params do
+ {
+ tmpfiles: { 'first_tmpfile.conf' => { 'content' => 'foo' }, 'second_tmpfile.conf' => { 'content' => 'bar' }, },
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_systemd__tmpfile('first_tmpfile.conf').with_content('foo') }
+ it { is_expected.to contain_systemd__tmpfile('second_tmpfile.conf').with_content('bar') }
+ it { is_expected.to contain_file('/etc/tmpfiles.d/first_tmpfile.conf') }
+ it { is_expected.to contain_file('/etc/tmpfiles.d/second_tmpfile.conf') }
+ it { is_expected.to have_systemd__tmpfile_resource_count(2) }
+ end
+ context 'when passing unit_files' do
+ let :params do
+ {
+ unit_files: { 'first.service' => { 'content' => 'foo' }, 'second.service' => { 'content' => 'bar' }, },
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_systemd__unit_file('first.service').with_content('foo') }
+ it { is_expected.to contain_systemd__unit_file('second.service').with_content('bar') }
+ it { is_expected.to contain_file('/etc/systemd/system/first.service') }
+ it { is_expected.to contain_file('/etc/systemd/system/second.service') }
+ it { is_expected.to have_systemd__unit_file_resource_count(2) }
+ end
context 'when managing Accounting options' do
let :params do
{