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

add factory for dropin files #149

Merged
merged 2 commits into from
Jul 16, 2020
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: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ use `daemon_reload => 'eager'` instead of the default `'lazy'`. Be aware that t
reloaded multiple times if you have multiple `systemd::dropin_file` resources and any one of them
is using `'eager'`.

dropin-files can also be generated via hiera:

```yaml

systemd::dropin_files:
my-foo.conf:
unit: foo.service
source: puppet:///modules/${module_name}/foo.conf

```

### tmpfiles

Let this module handle file creation and systemd reloading
Expand Down
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
# @param logind_settings
# Config Hash that is used to configure settings in logind.conf
#
# @param drpoin_files
# Configure dropin files via hiera with factory pattern
class systemd (
Hash[String,Hash[String, Any]] $service_limits,
Boolean $manage_resolved,
Expand Down Expand Up @@ -108,6 +110,7 @@
Systemd::JournaldSettings $journald_settings,
Boolean $manage_logind,
Systemd::LogindSettings $logind_settings,
Hash $dropin_files = {},
){

contain systemd::systemctl::daemon_reload
Expand Down Expand Up @@ -137,4 +140,10 @@
if $manage_logind {
contain systemd::logind
}

$dropin_files.each |$name, $resource| {
systemd::dropin_file { $name:
* => $resource,
}
}
}
14 changes: 14 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,20 @@
)
}
end
context 'when passing dropin_files' do
let(:params) do
{
dropin_files: {
'my-foo.conf' => {
'unit' => 'foo.service',
'content' => '[Service]\nReadWritePaths=/',
},
},
}
end

it { is_expected.to contain_systemd__dropin_file('my-foo.conf').with_content('[Service]\nReadWritePaths=/') }
end
end
end
end
Expand Down