Showing with 72 additions and 18 deletions.
  1. +19 −4 CHANGELOG.md
  2. +6 −0 README.md
  3. +1 −1 Rakefile
  4. +30 −11 manifests/dropin_file.pp
  5. +1 −1 metadata.json
  6. +15 −1 spec/defines/dropin_file_spec.rb
23 changes: 19 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v2.5.1](https://github.com/camptocamp/puppet-systemd/tree/v2.5.1) (2019-05-29)
## [2.6.0](https://github.com/camptocamp/puppet-systemd/tree/2.6.0) (2019-06-16)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.5.0...v2.5.1)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.5.1...2.6.0)

**Implemented enhancements:**

- Allow for lazy/eager systemctl daemon reloading [\#111](https://github.com/camptocamp/puppet-systemd/pull/111) ([JohnLyman](https://github.com/JohnLyman))

**Merged pull requests:**

- Remove stray `v` from Changelog `config.future\_release` [\#110](https://github.com/camptocamp/puppet-systemd/pull/110) ([alexjfisher](https://github.com/alexjfisher))

## [2.5.1](https://github.com/camptocamp/puppet-systemd/tree/2.5.1) (2019-05-29)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.5.0...2.5.1)

**Merged pull requests:**

Expand Down Expand Up @@ -51,7 +63,6 @@ These should not affect the functionality of the module.
- Manage journald service and configuration [\#89](https://github.com/camptocamp/puppet-systemd/pull/89) ([treydock](https://github.com/treydock))
- Add support for DNSoverTLS [\#88](https://github.com/camptocamp/puppet-systemd/pull/88) ([shibumi](https://github.com/shibumi))
- unit.d directory should be purged of unmanaged dropin files [\#41](https://github.com/camptocamp/puppet-systemd/pull/41) ([treydock](https://github.com/treydock))
- Add Journald support [\#14](https://github.com/camptocamp/puppet-systemd/pull/14) ([duritong](https://github.com/duritong))

**Closed issues:**

Expand Down Expand Up @@ -109,7 +120,6 @@ These should not affect the functionality of the module.
- purge legacy puppet-lint checks [\#66](https://github.com/camptocamp/puppet-systemd/pull/66) ([bastelfreak](https://github.com/bastelfreak))
- Reuse the systemd::dropin\_file in service\_limits [\#61](https://github.com/camptocamp/puppet-systemd/pull/61) ([ekohl](https://github.com/ekohl))
- cleanup README.md [\#60](https://github.com/camptocamp/puppet-systemd/pull/60) ([bastelfreak](https://github.com/bastelfreak))
- implement github changelog generator [\#45](https://github.com/camptocamp/puppet-systemd/pull/45) ([bastelfreak](https://github.com/bastelfreak))

## [1.1.1](https://github.com/camptocamp/puppet-systemd/tree/1.1.1) (2017-11-29)

Expand All @@ -136,6 +146,10 @@ These should not affect the functionality of the module.

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/1.0.0...1.1.0)

**Implemented enhancements:**

- Add Journald support [\#14](https://github.com/camptocamp/puppet-systemd/pull/14) ([duritong](https://github.com/duritong))

**Closed issues:**

- Add explicit ordering to README.md [\#24](https://github.com/camptocamp/puppet-systemd/issues/24)
Expand All @@ -161,6 +175,7 @@ These should not affect the functionality of the module.

**Merged pull requests:**

- implement github changelog generator [\#45](https://github.com/camptocamp/puppet-systemd/pull/45) ([bastelfreak](https://github.com/bastelfreak))
- Add support for drop-in files [\#39](https://github.com/camptocamp/puppet-systemd/pull/39) ([countsudoku](https://github.com/countsudoku))
- Adds control group limits to ServiceLimits [\#36](https://github.com/camptocamp/puppet-systemd/pull/36) ([trevor-vaughan](https://github.com/trevor-vaughan))
- it's systemd not SystemD [\#33](https://github.com/camptocamp/puppet-systemd/pull/33) ([shibumi](https://github.com/shibumi))
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ service {'foo':
}
```

Sometimes it's desirable to reload the systemctl daemon before a service is refreshed (for example:
when overriding `ExecStart` or adding environment variables to the drop-in file). In that case,
use `daemon_reload => 'eager'` instead of the default `'lazy'`. Be aware that the daemon could be
reloaded multiple times if you have multiple `systemd::dropin_file` resources and any one of them
is using `'eager'`.

### tmpfiles

Let this module handle file creation and systemd reloading
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ begin
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
version = (Blacksmith::Modulefile.new).version
config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/
config.future_release = version if version =~ /^\d+\.\d+.\d+$/
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
config.user = 'camptocamp'
Expand Down
41 changes: 30 additions & 11 deletions manifests/dropin_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,26 @@
# @attr show_diff
# Whether to show the diff when updating dropin file
#
# @attr daemon_reload
# Set to `lazy` to defer execution of a systemctl daemon reload.
# Minimizes the number of times the daemon is reloaded.
# Set to `eager` to immediately reload after the dropin file is updated.
# Useful if the daemon needs to be reloaded before a service is refreshed.
# May cause multiple daemon reloads.
#
define systemd::dropin_file(
Systemd::Unit $unit,
Systemd::Dropin $filename = $name,
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[String] $content = undef,
Optional[String] $source = undef,
Optional[Stdlib::Absolutepath] $target = undef,
String $owner = 'root',
String $group = 'root',
String $mode = '0444',
Boolean $show_diff = true,
Systemd::Dropin $filename = $name,
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[String] $content = undef,
Optional[String] $source = undef,
Optional[Stdlib::Absolutepath] $target = undef,
String $owner = 'root',
String $group = 'root',
String $mode = '0444',
Boolean $show_diff = true,
Enum['lazy', 'eager'] $daemon_reload = 'lazy',
) {
include systemd

Expand Down Expand Up @@ -82,6 +90,17 @@
group => $group,
mode => $mode,
show_diff => $show_diff,
notify => Class['systemd::systemctl::daemon_reload'],
}

if $daemon_reload == 'lazy' {
File["${path}/${unit}.d/${filename}"] ~> Class['systemd::systemctl::daemon_reload']
} else {
File["${path}/${unit}.d/${filename}"] ~> Exec["${unit}-systemctl-daemon-reload"]

exec { "${unit}-systemctl-daemon-reload":
command => 'systemctl daemon-reload',
refreshonly => true,
path => $facts['path'],
}
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camptocamp-systemd",
"version": "2.5.1",
"version": "2.6.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down
16 changes: 15 additions & 1 deletion spec/defines/dropin_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@
:mode => '0444'
) }

it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").that_notifies('Class[systemd::systemctl::daemon_reload]') }
context 'with daemon_reload => lazy (default)' do
it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").that_notifies('Class[systemd::systemctl::daemon_reload]') }

it { is_expected.not_to create_exec("#{params[:unit]}-systemctl-daemon-reload") }
end

context 'with daemon_reload => eager' do
let(:params) do
super().merge({ :daemon_reload => 'eager' })
end

it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").that_notifies("Exec[#{params[:unit]}-systemctl-daemon-reload]") }

it { is_expected.to create_exec("#{params[:unit]}-systemctl-daemon-reload") }
end

context 'with a bad unit type' do
let(:title) { 'test.badtype' }
Expand Down