32 changes: 26 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ 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.

## [2.6.0](https://github.com/camptocamp/puppet-systemd/tree/2.6.0) (2019-06-16)
## [2.7.0](https://github.com/camptocamp/puppet-systemd/tree/2.7.0) (2019-10-28)

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

**Implemented enhancements:**

- add support for 'VirtuozzoLinux 7' [\#121](https://github.com/camptocamp/puppet-systemd/pull/121) ([kBite](https://github.com/kBite))
- Manage logind service and configuration [\#120](https://github.com/camptocamp/puppet-systemd/pull/120) ([fraenki](https://github.com/fraenki))

**Fixed bugs:**

- Correct order when ensuring unit files are absent [\#122](https://github.com/camptocamp/puppet-systemd/pull/122) ([ekohl](https://github.com/ekohl))

**Closed issues:**

- vacuum as routine task [\#123](https://github.com/camptocamp/puppet-systemd/issues/123)
- Manage dropin\_file for target type systemd unit [\#117](https://github.com/camptocamp/puppet-systemd/issues/117)
- Allow Sensitive type for systemd::dropin\_file::content [\#114](https://github.com/camptocamp/puppet-systemd/issues/114)

**Merged pull requests:**

- allow Sensitive type for content param [\#115](https://github.com/camptocamp/puppet-systemd/pull/115) ([TheMeier](https://github.com/TheMeier))

## [2.6.0](https://github.com/camptocamp/puppet-systemd/tree/2.6.0) (2019-06-17)

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

Expand Down Expand Up @@ -63,6 +86,7 @@ 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 @@ -120,6 +144,7 @@ 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 @@ -146,10 +171,6 @@ 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 @@ -175,7 +196,6 @@ 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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ systemd::network{'eth0.network':
### Services

Systemd provides multiple services. Currently you can manage `systemd-resolved`,
`systemd-timesyncd` and `systemd-networkd` via the main class:
`systemd-timesyncd`, `systemd-networkd`, `systemd-journald` and `systemd-logind`
via the main class:

```puppet
class{'systemd':
manage_resolved => true,
manage_networkd => true,
manage_timesyncd => true,
manage_journald => true,
manage_logind => true,
}
```

Expand Down Expand Up @@ -226,3 +229,16 @@ systemd::journald_settings:
MaxLevelStore:
ensure: absent
```
### logind configuration
It also allows you to manage logind settings. You can manage logind settings through setting the `logind_settings` parameter. If you want a parameter to be removed, you can pass its value as params.

```yaml
systemd::logind_settings:
HandleSuspendKey: 'ignore'
KillUserProcesses: 'no'
RemoveIPC:
ensure: absent
UserTasksMax: 10000
```
6 changes: 6 additions & 0 deletions data/VirtuozzoLinux-7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
systemd::accounting:
DefaultCPUAccounting: 'yes'
DefaultBlockIOAccounting: 'yes'
DefaultMemoryAccounting: 'yes'
DefaultTasksAccounting: 'yes'
2 changes: 2 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ systemd::accounting: {}
systemd::purge_dropin_dirs: true
systemd::manage_journald: true
systemd::journald_settings: {}
systemd::manage_logind: false
systemd::logind_settings: {}
24 changes: 12 additions & 12 deletions manifests/dropin_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@
# 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,
Enum['lazy', 'eager'] $daemon_reload = 'lazy',
Systemd::Unit $unit,
Systemd::Dropin $filename = $name,
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[Variant[String,Sensitive[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
12 changes: 12 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
# @param journald_settings
# Config Hash that is used to configure settings in journald.conf
#
# @param manage_logind
# Manage the systemd logind
#
# @param logind_settings
# Config Hash that is used to configure settings in logind.conf
#
class systemd (
Hash[String,Hash[String, Any]] $service_limits,
Boolean $manage_resolved,
Expand All @@ -100,6 +106,8 @@
Boolean $purge_dropin_dirs,
Boolean $manage_journald,
Systemd::JournaldSettings $journald_settings,
Boolean $manage_logind,
Systemd::LogindSettings $logind_settings,
){

contain systemd::systemctl::daemon_reload
Expand All @@ -125,4 +133,8 @@
if $manage_journald {
contain systemd::journald
}

if $manage_logind {
contain systemd::logind
}
}
31 changes: 31 additions & 0 deletions manifests/logind.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @api private
#
# This class manages systemd's login manager configuration.
#
# https://www.freedesktop.org/software/systemd/man/logind.conf.html
class systemd::logind {

assert_private()

service{'systemd-logind':
ensure => running,
}
$systemd::logind_settings.each |$option, $value| {
ini_setting{
$option:
path => '/etc/systemd/logind.conf',
section => 'Login',
setting => $option,
notify => Service['systemd-logind'],
}
if $value =~ Hash {
Ini_setting[$option]{
* => $value,
}
} else {
Ini_setting[$option]{
value => $value,
}
}
}
}
43 changes: 27 additions & 16 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,48 @@
#
# @see systemd.unit(5)
#
# @attr name [Pattern['^.+\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$']]
# @param name [Pattern['^.+\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$']]
# The target unit file to create
#
# * Must not contain ``/``
#
# @attr path
# @param ensure
# The state of the unit file to ensure
#
# @param path
# The main systemd configuration path
#
# @attr content
# @param content
# The full content of the unit file
#
# * Mutually exclusive with ``$source``
#
# @attr source
# @param source
# The ``File`` resource compatible ``source``
#
# * Mutually exclusive with ``$content``
#
# @attr target
# @param target
# If set, will force the file to be a symlink to the given target
#
# * Mutually exclusive with both ``$source`` and ``$content``
#
# @attr owner
# @param owner
# The owner to set on the unit file
#
# @attr group
# @param group
# The group to set on the unit file
#
# @attr mode
# @param mode
# The mode to set on the unit file
#
# @attr show_diff
# @param show_diff
# Whether to show the diff when updating unit file
#
# @attr enable
# @param enable
# If set, will manage the unit enablement status.
#
# @attr active
# @param active
# If set, will manage the state of the unit.
#
define systemd::unit_file(
Expand Down Expand Up @@ -85,11 +88,19 @@

if $enable != undef or $active != undef {
service { $name:
ensure => $active,
enable => $enable,
provider => 'systemd',
subscribe => File["${path}/${name}"],
require => Class['systemd::systemctl::daemon_reload'],
ensure => $active,
enable => $enable,
provider => 'systemd',
}

if $ensure == 'absent' {
if $enable or $active {
fail("Can't ensure the unit file is absent and activate/enable the service at the same time")
}
Service[$name] -> File["${path}/${name}"]
} else {
Class['systemd::systemctl::daemon_reload'] -> Service[$name]
File["${path}/${name}"] ~> Service[$name]
}
}
}
8 changes: 7 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camptocamp-systemd",
"version": "2.6.0",
"version": "2.7.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down Expand Up @@ -45,6 +45,12 @@
"7"
]
},
{
"operatingsystem": "VirtuozzoLinux",
"operatingsystemrelease": [
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
Expand Down
45 changes: 45 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,51 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_service('systemd-journald') }
end

context 'when enabling logind with options' do
let(:params) do
{
:manage_logind => true,
:logind_settings => {
'HandleSuspendKey' => 'ignore',
'KillUserProcesses' => 'no',
'RemoveIPC' => {
'ensure' => 'absent',
},
'UserTasksMax' => '10000',
}
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_service('systemd-logind').with(
:ensure => 'running'
) }
it { is_expected.to have_ini_setting_resource_count(4) }
it { is_expected.to contain_ini_setting('HandleSuspendKey').with(
:path => '/etc/systemd/logind.conf',
:section => 'Login',
:notify => 'Service[systemd-logind]',
:value => 'ignore',
)}
it { is_expected.to contain_ini_setting('KillUserProcesses').with(
:path => '/etc/systemd/logind.conf',
:section => 'Login',
:notify => 'Service[systemd-logind]',
:value => 'no',
)}
it { is_expected.to contain_ini_setting('RemoveIPC').with(
:path => '/etc/systemd/logind.conf',
:section => 'Login',
:notify => 'Service[systemd-logind]',
:ensure => 'absent',
)}
it { is_expected.to contain_ini_setting('UserTasksMax').with(
:path => '/etc/systemd/logind.conf',
:section => 'Login',
:notify => 'Service[systemd-logind]',
:value => '10000',
)}
end
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/defines/dropin_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@
:mode => '0444'
) }
end
context 'with sensitve content' do
let(:title) { 'sensitive.conf' }
let(:params) {{
:unit => 'sensitive.service',
:content => RSpec::Puppet::RawString.new("Sensitive('TEST_CONTENT')")
}}

it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").with(
:ensure => 'file',
:content => 'TEST_CONTENT'
) }

end
end
end
end
Expand Down
Loading