8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
-
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
stage: static
-
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.5
stage: spec
-
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
rvm: 2.5.7
stage: spec
-
env: PUPPET_GEM_VERSION="~> 7.0" CHECK=parallel_spec
rvm: 2.7.2
stage: spec
-
env: DEPLOY_TO_FORGE=yes
stage: deploy
Expand Down
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [3.0.0](https://github.com/camptocamp/puppet-systemd/tree/3.0.0) (2021-04-16)

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

**Breaking changes:**

- Drop Puppet 4 and 5 support + daemon-reload code [\#171](https://github.com/camptocamp/puppet-systemd/pull/171) ([ekohl](https://github.com/ekohl))

**Implemented enhancements:**

- add ubuntu2004 [\#187](https://github.com/camptocamp/puppet-systemd/pull/187) ([GervaisdeM](https://github.com/GervaisdeM))
- allow Puppet 7 and add to Travis testing; remove Puppet 5 from Travis testing [\#183](https://github.com/camptocamp/puppet-systemd/pull/183) ([kenyon](https://github.com/kenyon))
- metadata: allow stdlib 7.0.0 and inifile 5.0.0 [\#182](https://github.com/camptocamp/puppet-systemd/pull/182) ([kenyon](https://github.com/kenyon))

**Closed issues:**

- Static units cannot be enabled [\#180](https://github.com/camptocamp/puppet-systemd/issues/180)
- Cyclic dependency error when using systemd::unit\_file in multiple classes [\#178](https://github.com/camptocamp/puppet-systemd/issues/178)

**Merged pull requests:**

- Bump version to 3.0.0-rc0 [\#186](https://github.com/camptocamp/puppet-systemd/pull/186) ([ekohl](https://github.com/ekohl))
- Correct path in use\_stub\_resolver documentation [\#177](https://github.com/camptocamp/puppet-systemd/pull/177) ([ekohl](https://github.com/ekohl))

## [2.12.0](https://github.com/camptocamp/puppet-systemd/tree/2.12.0) (2021-02-10)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.11.0...2.12.0)
Expand Down Expand Up @@ -96,15 +120,15 @@ All notable changes to this project will be documented in this file. The format
### Added

- Allow for lazy/eager systemctl daemon reloading [\#111](https://github.com/camptocamp/puppet-systemd/pull/111) ([JohnLyman](https://github.com/JohnLyman))
- Remove stray `v` from Changelog `config.future\_release` [\#110](https://github.com/camptocamp/puppet-systemd/pull/110) ([alexjfisher](https://github.com/alexjfisher))
- 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)

### Added

- Pin `public\_suffix` to `3.0.3` on rvm 2.1.9 builds [\#108](https://github.com/camptocamp/puppet-systemd/pull/108) ([alexjfisher](https://github.com/alexjfisher))
- Pin `public_suffix` to `3.0.3` on rvm 2.1.9 builds [\#108](https://github.com/camptocamp/puppet-systemd/pull/108) ([alexjfisher](https://github.com/alexjfisher))
- run CI jobs on xenial instead of trusty [\#107](https://github.com/camptocamp/puppet-systemd/pull/107) ([bastelfreak](https://github.com/bastelfreak))

## [2.5.0](https://github.com/camptocamp/puppet-systemd/tree/2.5.0) (2019-05-29)
Expand Down
41 changes: 14 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ There are two ways to use this module.

### unit files

Let this module handle file creation and systemd reloading.
Let this module handle file creation.

```puppet
systemd::unit_file { 'foo.service':
Expand All @@ -29,23 +29,18 @@ systemd::unit_file { 'foo.service':
}
```

Or handle file creation yourself and trigger systemd.
This is equivalent to:

```puppet
include systemd::systemctl::daemon_reload
file { '/usr/lib/systemd/system/foo.service':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => "puppet:///modules/${module_name}/foo.service",
}
~> Class['systemd::systemctl::daemon_reload']
service {'foo':
ensure => 'running',
subscribe => File['/usr/lib/systemd/system/foo.service'],
~> service {'foo':
ensure => 'running',
}
```

Expand All @@ -63,7 +58,7 @@ systemd::unit_file { 'foo.service':

Drop-in files are used to add or alter settings of a unit without modifying the
unit itself. As for the unit files, the module can handle the file and
directory creation and systemd reloading:
directory creation:

```puppet
systemd::dropin_file { 'foo.conf':
Expand All @@ -75,11 +70,9 @@ systemd::dropin_file { 'foo.conf':
}
```

Or handle file and directory creation yourself and trigger systemd:
This is equivalent to:

```puppet
include systemd::systemctl::daemon_reload
file { '/etc/systemd/system/foo.service.d':
ensure => directory,
owner => 'root',
Expand All @@ -93,29 +86,18 @@ file { '/etc/systemd/system/foo.service.d/foo.conf':
mode => '0644',
source => "puppet:///modules/${module_name}/foo.conf",
}
~> Class['systemd::systemctl::daemon_reload']
service {'foo':
ensure => 'running',
subscribe => File['/etc/systemd/system/foo.service.d/foo.conf'],
~> service {'foo':
ensure => 'running',
}
```

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'`.

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
Expand Down Expand Up @@ -148,7 +130,6 @@ Create a systemd timer unit and a systemd service unit to execute from
that timer

The following will create a timer unit and a service unit file.
The execution of `systemctl daemon-reload` will occur.
When `active` and `enable` are set to `true` the puppet service `runoften.timer` will be
declared, started and enabled.

Expand Down Expand Up @@ -240,6 +221,12 @@ systemd::service_limits { 'foo.service':
}
```

### Daemon reloads

Systemd caches unit files and their relations. This means it needs to reload, typically done via `systemctl daemon-reload`. Since Puppet 6.1.0 ([PUP-3483](https://tickets.puppetlabs.com/browse/PUP-3483)) takes care of this by calling `systemctl show $SERVICE -- --property=NeedDaemonReload` to determine if a reload is needed. Typically this works well and removes the need for `systemd::systemctl::daemon_reload` as provided prior to camptocamp/systemd 3.0.0. This avoids common circular dependencies.

It does contain a workaround for [PUP-9473](https://tickets.puppetlabs.com/browse/PUP-9473) but there's no guarantee that this works in every case.

### network

systemd-networkd is able to manage your network configuration. We provide a
Expand Down
13 changes: 0 additions & 13 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#### Public Classes

* [`systemd`](#systemd): This module allows triggering systemd commands once for all modules
* [`systemd::systemctl::daemon_reload`](#systemdsystemctldaemon_reload): Reload the systemctl daemon
* [`systemd::tmpfiles`](#systemdtmpfiles): Update the systemd temp files

#### Private Classes
Expand Down Expand Up @@ -238,10 +237,6 @@ Data type: `Boolean`



### `systemd::systemctl::daemon_reload`

Reload the systemctl daemon

### `systemd::tmpfiles`

Update the systemd temp files
Expand Down Expand Up @@ -371,14 +366,6 @@ Data type: `Boolean`

Default value: ``true``

##### `daemon_reload`

Data type: `Enum['lazy', 'eager']`



Default value: `'lazy'`

### `systemd::network`

-- Define: systemd::network
Expand Down
8 changes: 8 additions & 0 deletions data/Ubuntu-20.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
systemd::accounting:
DefaultCPUAccounting: 'yes'
DefaultIOAccounting: 'yes'
DefaultIPAccounting: 'yes'
DefaultBlockIOAccounting: 'yes'
DefaultMemoryAccounting: 'yes'
DefaultTasksAccounting: 'yes'
20 changes: 0 additions & 20 deletions manifests/dropin_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
# @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,
Expand All @@ -60,7 +53,6 @@
String $group = 'root',
String $mode = '0444',
Boolean $show_diff = true,
Enum['lazy', 'eager'] $daemon_reload = 'lazy',
) {
include systemd

Expand Down Expand Up @@ -95,16 +87,4 @@
selinux_ignore_defaults => $selinux_ignore_defaults,
show_diff => $show_diff,
}

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'],
}
}
}
6 changes: 2 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param use_stub_resolver
# Takes a boolean argument. When "false" (default) it uses /var/run/systemd/resolve/resolv.conf
# as /etc/resolv.conf. When "true", it uses /var/run/systemd/resolve/stub-resolv.conf
# 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
# @param manage_networkd
# Manage the systemd network daemon
#
Expand Down Expand Up @@ -150,8 +150,6 @@
Hash $dropin_files = {},
Hash $udev_rules = {},
) {
contain systemd::systemctl::daemon_reload

create_resources('systemd::service_limits', $service_limits)

if $manage_resolved and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-resolved.service'] {
Expand Down
4 changes: 2 additions & 2 deletions manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param use_stub_resolver
# Takes a boolean argument. When "false" (default) it uses /var/run/systemd/resolve/resolv.conf
# as /etc/resolv.conf. When "true", it uses /var/run/systemd/resolve/stub-resolv.conf
# 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
#
class systemd::resolved (
Enum['stopped','running'] $ensure = $systemd::resolved_ensure,
Expand Down
1 change: 0 additions & 1 deletion manifests/service_limits.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
path => $::path,
refreshonly => true,
subscribe => File["${path}/${name}.d/90-limits.conf"],
require => Class['systemd::systemctl::daemon_reload'],
}
}
}
1 change: 0 additions & 1 deletion manifests/system.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
section => 'Manager',
setting => $option,
value => $value,
notify => Class['systemd::systemctl::daemon_reload'],
}
}
}
10 changes: 0 additions & 10 deletions manifests/systemctl/daemon_reload.pp

This file was deleted.

10 changes: 8 additions & 2 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
group => $group,
mode => $mode,
show_diff => $show_diff,
notify => Class['systemd::systemctl::daemon_reload'],
}

if $enable != undef or $active != undef {
Expand All @@ -103,8 +102,15 @@
}
Service[$name] -> File["${path}/${name}"]
} else {
Class['systemd::systemctl::daemon_reload'] -> Service[$name]
File["${path}/${name}"] ~> Service[$name]
}
} elsif $ensure == 'absent' {
# Work around https://tickets.puppetlabs.com/browse/PUP-9473
exec { "${name}-systemctl-daemon-reload":
command => 'systemctl daemon-reload',
refreshonly => true,
path => $facts['path'],
subscribe => File["${path}/${name}"],
}
}
}
11 changes: 6 additions & 5 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camptocamp-systemd",
"version": "2.12.0",
"version": "3.0.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand All @@ -10,11 +10,11 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 7.0.0"
"version_requirement": ">= 4.13.1 < 8.0.0"
},
{
"name": "puppetlabs/inifile",
"version_requirement": ">= 1.6.0 < 5.0.0"
"version_requirement": ">= 1.6.0 < 6.0.0"
}
],
"operatingsystem_support": [
Expand All @@ -30,7 +30,8 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"16.04",
"18.04"
"18.04",
"20.04"
]
},
{
Expand Down Expand Up @@ -81,7 +82,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.10.10 < 7.0.0"
"version_requirement": ">= 6.1.0 < 8.0.0"
}
],
"pdk-version": "1.18.0",
Expand Down
1 change: 0 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

it { is_expected.to compile.with_all_deps }
it { is_expected.to create_class('systemd') }
it { is_expected.to create_class('systemd::systemctl::daemon_reload') }
it { is_expected.to contain_class('systemd::journald') }
it { is_expected.to create_service('systemd-journald') }
it { is_expected.to have_ini_setting_resource_count(0) }
Expand Down
Loading