2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
Rakefile:
changelog_version_tag_pattern: '%s'
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ matrix:
branches:
only:
- master
- /^v\d/
- /^\d/
notifications:
email: false
Expand Down
38 changes: 31 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [2.9.0](https://github.com/camptocamp/puppet-systemd/tree/2.9.0) (2020-03-09)

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

**Implemented enhancements:**

- Add EL8 Support [\#144](https://github.com/camptocamp/puppet-systemd/pull/144) ([trevor-vaughan](https://github.com/trevor-vaughan))
- Add Fedora 30/31 compatibility [\#141](https://github.com/camptocamp/puppet-systemd/pull/141) ([bastelfreak](https://github.com/bastelfreak))
- New systemd::timer define type [\#138](https://github.com/camptocamp/puppet-systemd/pull/138) ([mmoll](https://github.com/mmoll))
- Add SLES 12/15 support [\#137](https://github.com/camptocamp/puppet-systemd/pull/137) ([msurato](https://github.com/msurato))

**Closed issues:**

- Discussion: use class instead of exec for notification [\#2](https://github.com/camptocamp/puppet-systemd/issues/2)

**Merged pull requests:**

- fix Issue 113 [\#140](https://github.com/camptocamp/puppet-systemd/pull/140) ([schlitzered](https://github.com/schlitzered))

## [2.8.0](https://github.com/camptocamp/puppet-systemd/tree/2.8.0) (2020-01-08)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.7.0...2.8.0)
Expand All @@ -16,8 +35,10 @@

**Merged pull requests:**

- Release 2.8.0 [\#134](https://github.com/camptocamp/puppet-systemd/pull/134) ([raphink](https://github.com/raphink))
- Convert to PDK [\#132](https://github.com/camptocamp/puppet-systemd/pull/132) ([raphink](https://github.com/raphink))
- Add loginctl\_user type/provider [\#131](https://github.com/camptocamp/puppet-systemd/pull/131) ([raphink](https://github.com/raphink))
- Force tmpfiles.d drop file to end in .conf [\#129](https://github.com/camptocamp/puppet-systemd/pull/129) ([traylenator](https://github.com/traylenator))
- allow puppetlabs/inifile 4.x [\#126](https://github.com/camptocamp/puppet-systemd/pull/126) ([bastelfreak](https://github.com/bastelfreak))

## [2.7.0](https://github.com/camptocamp/puppet-systemd/tree/2.7.0) (2019-10-29)
Expand Down Expand Up @@ -203,6 +224,11 @@

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

**Implemented enhancements:**

- 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))

**Closed issues:**

- PR\#18 broke service limits capacity [\#35](https://github.com/camptocamp/puppet-systemd/issues/35)
Expand All @@ -212,8 +238,6 @@

**Merged pull requests:**

- 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))
- General cleanup + add Puppet4 datatypes [\#32](https://github.com/camptocamp/puppet-systemd/pull/32) ([bastelfreak](https://github.com/bastelfreak))
- add management for systemd-resolved [\#31](https://github.com/camptocamp/puppet-systemd/pull/31) ([bastelfreak](https://github.com/bastelfreak))
Expand All @@ -228,16 +252,16 @@

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

**Implemented enhancements:**

- Add target param for the unit file [\#10](https://github.com/camptocamp/puppet-systemd/pull/10) ([tampakrap](https://github.com/tampakrap))
- only use awk, instead of grep and awk [\#9](https://github.com/camptocamp/puppet-systemd/pull/9) ([igalic](https://github.com/igalic))

**Closed issues:**

- No LICENSE file [\#11](https://github.com/camptocamp/puppet-systemd/issues/11)
- Forge update [\#7](https://github.com/camptocamp/puppet-systemd/issues/7)

**Merged pull requests:**

- Add target param for the unit file [\#10](https://github.com/camptocamp/puppet-systemd/pull/10) ([tampakrap](https://github.com/tampakrap))
- only use awk, instead of grep and awk [\#9](https://github.com/camptocamp/puppet-systemd/pull/9) ([igalic](https://github.com/igalic))

## [0.3.0](https://forge.puppetlabs.com/camptocamp/systemd/0.3.0) (2016-05-16)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.2...0.3.0)

Expand Down
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,82 @@ file { '/etc/tmpfiles.d/foo.conf':
~> Class['systemd::tmpfiles']
```

### timer units
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.

```puppet
systemd::timer{'runoften.timer':
timer_source => "puppet:///modules/${module_name}/runoften.timer",
service_source => "puppet:///modules/${module_name}/runoften.service",
active => true,
enable => true,
}
```

A trivial daily run.
In this case enable and active are both unset and so the service `daily.timer`
is not declared by the `systemd::timer` type.

```puppet
$_timer = @(EOT)
[Timer]
OnCalendar=daily
RandomizedDelaySec=1d
EOT
$_service = @(EOT)
[Service]
Type=oneshot
ExecStart=/usr/bin/touch /tmp/file
EOT
systemd::timer{'daily.timer':
timer_content => $_timer,
service_content => $_service,
}
service{'daily.timer':
ensure => running,
subscribe => Systemd::Timer['daily.timer'],
}
```

If neither `service_content` or `service_source` are specified then no
service unit will be created.

The service unit name can also be specified.

```puppet
$_timer = @(EOT)
[Timer]
OnCalendar=daily
RandomizedDelaySec=1d
Unit=touch-me-today.service
EOT
$_service = @(EOT)
[Service]
Type=oneshot
ExecStart=/usr/bin/touch /tmp/file
EOT
systemd::timer{'daily.timer':
timer_content => $_timer,
service_unit => 'touch-me-today.service',
service_content => $_service,
active => true,
enable => true,
}
```

### service limits

Manage soft and hard limits on various resources for executed processes.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ end

def changelog_future_release
return unless Rake.application.top_level_tasks.include? "changelog"
returnVal = JSON.load(File.read('metadata.json'))['version']
returnVal = "%s" % JSON.load(File.read('metadata.json'))['version']
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator future_release:#{returnVal}"
returnVal
Expand Down
6 changes: 6 additions & 0 deletions data/CentOS-8.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'
8 changes: 8 additions & 0 deletions data/Fedora.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'
6 changes: 6 additions & 0 deletions data/OracleLinux-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'
6 changes: 6 additions & 0 deletions data/OracleLinux-8.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'
6 changes: 6 additions & 0 deletions data/RedHat-8.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'
6 changes: 6 additions & 0 deletions data/SLES-12.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'
6 changes: 6 additions & 0 deletions data/SLES-15.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'
5 changes: 3 additions & 2 deletions manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Takes a boolean argument or "opportunistic" or "no"
#
# @param cache
# Takes a boolean argument.
# Takes a boolean argument or "no-negative".
#
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
Expand All @@ -53,7 +53,7 @@
Optional[Variant[Boolean,Enum['resolve']]] $multicast_dns = $systemd::multicast_dns,
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec = $systemd::dnssec,
Optional[Variant[Boolean,Enum['opportunistic', 'no']]] $dnsovertls = $systemd::dnsovertls,
Boolean $cache = $systemd::cache,
Optional[Variant[Boolean,Enum['no-negative']]] $cache = $systemd::cache,
Optional[Variant[Boolean,Enum['udp', 'tcp']]] $dns_stub_listener = $systemd::dns_stub_listener,
Boolean $use_stub_resolver = $systemd::use_stub_resolver,
){
Expand Down Expand Up @@ -200,6 +200,7 @@
$_cache = $cache ? {
true => 'yes',
false => 'no',
default => $cache,
}

if $cache {
Expand Down
106 changes: 106 additions & 0 deletions manifests/timer.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# @summary Create a timer and optionally a service unit to execute with the timer unit
#
# @api public
#
# @see https://www.freedesktop.org/software/systemd/man/systemd.timer.html systemd.timer(5)
#
# @param name [Pattern['^.+\.timer$]]
# The target of the timer unit to create
#
# @param path
# The main systemd configuration path
#
# @param timer_content
# The full content of the timer unit file
#
# * Mutually exclusive with ``$timer_source``
#
# @param timer_source
# The ``File`` resource compatible ``source``
#
# * Mutually exclusive with ``$timer_content``
#
# @param service_content
# The full content of the service unit file
#
# * Mutually exclusive with ``$service_source``
#
# @param service_source
# The ``File`` resource compatible ``source``
#
# * Mutually exclusive with ``$service_content``
#
# @param owner
# The owner to set on the dropin file
#
# @param group
# The group to set on the dropin file
#
# @param mode
# The mode to set on the dropin file
#
# @param show_diff
# Whether to show the diff when updating dropin file
#
# @param service_unit
# If set then the service_unit will have this name.
# If not set the service unit has the same name
# as the timer unit with s/.timer/.service/
#
# @param active
# If set to true or false the timer service will be maintained.
# If true the timer service will be running and enabled, if false it will
# explictly stopped and disabled.
#
# @param enable
# If set, will manage the state of the unit.
#
define systemd::timer (
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[String[1]] $timer_content = undef,
Optional[String[1]] $timer_source = undef,
Optional[String[1]] $service_content = undef,
Optional[String[1]] $service_source = undef,
String[1] $owner = 'root',
String[1] $group = 'root',
Stdlib::Filemode $mode = '0444',
Optional[Systemd::Unit] $service_unit = undef,
Boolean $show_diff = true,
Optional[Variant[Boolean, Enum['mask']]] $enable = undef,
Optional[Boolean] $active = undef,
) {
assert_type(Pattern['^.+\.timer$'],$name)

if $service_unit {
$_service_unit = $service_unit
} else {
$_service_unit = "${basename($name,'.timer')}.service"
}

if $service_content or $service_source {
systemd::unit_file{$_service_unit:
ensure => $ensure,
content => $service_content,
source => $service_source,
path => $path,
owner => $owner,
group => $group,
mode => $mode,
show_diff => $show_diff,
}
}

systemd::unit_file{$name:
ensure => $ensure,
content => $timer_content,
source => $timer_source,
path => $path,
owner => $owner,
group => $group,
mode => $mode,
show_diff => $show_diff,
enable => $enable,
active => $active,
}
}
Loading