Showing with 143 additions and 87 deletions.
  1. +8 −4 .travis.yml
  2. +25 −7 CHANGELOG.md
  3. +9 −8 Gemfile
  4. +0 −5 HISTORY.md
  5. +2 −0 README.md
  6. +2 −2 Rakefile
  7. +1 −0 data/common.yaml
  8. +4 −0 manifests/init.pp
  9. +10 −1 manifests/resolved.pp
  10. +7 −5 manifests/service_limits.pp
  11. +1 −1 manifests/systemctl/daemon_reload.pp
  12. +2 −2 metadata.json
  13. +71 −51 spec/defines/service_limits_spec.rb
  14. +1 −1 types/servicelimits.pp
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
---
language: ruby
sudo: false
addons:
apt:
packages:
- libaugeas-dev
sources:
- augeas
cache: bundler
bundler_args: --without system_tests --without release
bundler_args: --without system_tests
script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'"]
matrix:
fast_finish: true
include:
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.0"
- rvm: 2.4.1
env: PUPPET_GEM_VERSION="~> 4"
- rvm: 2.4.1
env: PUPPET_GEM_VERSION="~> 5"
env: PUPPET_GEM_VERSION="~> 5.0"
notifications:
email: false
deploy:
Expand Down
32 changes: 25 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# Changelog

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.1.0](https://github.com/camptocamp/puppet-systemd/tree/v2.1.0) (2018-08-31)

## [2.0.0](https://github.com/camptocamp/puppet-systemd/tree/2.0.0) (2018-07-06)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.0.0...v2.1.0)

**Implemented enhancements:**

- Modify service limit type [\#81](https://github.com/camptocamp/puppet-systemd/pull/81) ([bastelfreak](https://github.com/bastelfreak))
- Add parameter to select resolver [\#79](https://github.com/camptocamp/puppet-systemd/pull/79) ([amateo](https://github.com/amateo))

**Fixed bugs:**

- Handle ensuring service\_limits to be absent [\#80](https://github.com/camptocamp/puppet-systemd/pull/80) ([ekohl](https://github.com/ekohl))

**Merged pull requests:**

- do not access facts as top scope variable [\#85](https://github.com/camptocamp/puppet-systemd/pull/85) ([bastelfreak](https://github.com/bastelfreak))
- Release 2.1.0 [\#84](https://github.com/camptocamp/puppet-systemd/pull/84) ([bastelfreak](https://github.com/bastelfreak))
- allow puppetlabs/stdlib 5.x [\#83](https://github.com/camptocamp/puppet-systemd/pull/83) ([bastelfreak](https://github.com/bastelfreak))
- Fix CHANGELOG.md duplicate footer [\#78](https://github.com/camptocamp/puppet-systemd/pull/78) ([alexjfisher](https://github.com/alexjfisher))

## [2.0.0](https://github.com/camptocamp/puppet-systemd/tree/2.0.0) (2018-07-11)

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

Expand All @@ -26,6 +48,7 @@
**Merged pull requests:**

- fix puppet-linter warnings in README.md [\#75](https://github.com/camptocamp/puppet-systemd/pull/75) ([bastelfreak](https://github.com/bastelfreak))
- release 2.0.0 [\#70](https://github.com/camptocamp/puppet-systemd/pull/70) ([bastelfreak](https://github.com/bastelfreak))
- Update the documentation of facts [\#68](https://github.com/camptocamp/puppet-systemd/pull/68) ([ekohl](https://github.com/ekohl))
- 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))
Expand Down Expand Up @@ -108,8 +131,6 @@
- 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))

# Change Log

## [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 Expand Up @@ -178,7 +199,4 @@
- Confine rspec pinning to ruby 1.8


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*


\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
17 changes: 9 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ group :development, :unit_tests do
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1\./
gem 'ruby-augeas', :require => false
gem 'json_pure', '< 2.0.2', :require => false
end

group :release do
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator.git'
end

group :system_tests do
gem 'beaker', :require => false
gem 'beaker', '~>3.13', :require => false
gem 'beaker-rspec', '> 5', :require => false
gem 'beaker_spec_helper', :require => false
gem 'serverspec', :require => false
Expand All @@ -37,8 +33,7 @@ end
if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
# There are no facts in place for facter > 2.4 in rspec-puppet-facts yet
gem 'facter', '~> 2.5.0', :require => false
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
Expand All @@ -47,4 +42,10 @@ else
gem 'puppet', :require => false
end

group :release do
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' if RUBY_VERSION >= '2.2.2'
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem'
end

# vim:ft=ruby
5 changes: 0 additions & 5 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Change Log

## [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 Expand Up @@ -66,6 +64,3 @@
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.6...0.1.7)

- Confine rspec pinning to ruby 1.8


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ $manage_networkd is required if you want to reload it for new
`systemd::network` resources. Setting $manage_resolved will also manage your
`/etc/resolv.conf`.

When configuring `systemd::resolved` you could set `dns_stub_resolver` to false (default) to use a *standard* `/etc/resolved.conf`, or you could set it to `true` to use the local resolver provided by `systemd-resolved`.

It is possible to configure the default ntp servers in /etc/systemd/timesyncd.conf:

```puppet
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ begin
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
version = (Blacksmith::Modulefile.new).version
config.future_release = "#{version}" if version =~ /^\d+\.\d+.\d+$/
config.header = "# Changelog\n\n"
config.future_release = "v#{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'
config.project = 'puppet-systemd'
Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ systemd::multicast_dns: ~
systemd::dnssec: ~
systemd::cache: false
systemd::dns_stub_listener: ~
systemd::use_stub_resolver: false
systemd::manage_networkd: false
systemd::networkd_ensure: 'running'
systemd::manage_timesyncd: false
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# @param dns_stub_listener
# 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
# @param manage_networkd
# Manage the systemd network daemon
#
Expand Down Expand Up @@ -74,6 +77,7 @@
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec,
Boolean $cache,
Optional[Variant[Boolean,Enum['udp','tcp']]] $dns_stub_listener,
Boolean $use_stub_resolver,
Boolean $manage_networkd,
Enum['stopped','running'] $networkd_ensure,
Boolean $manage_timesyncd,
Expand Down
11 changes: 10 additions & 1 deletion manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
# @param dns_stub_listener
# 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
#
class systemd::resolved (
Enum['stopped','running'] $ensure = $systemd::resolved_ensure,
Optional[Variant[Array[String],String]] $dns = $systemd::dns,
Expand All @@ -47,6 +51,7 @@
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec = $systemd::dnssec,
Boolean $cache = $systemd::cache,
Optional[Variant[Boolean,Enum['udp', 'tcp']]] $dns_stub_listener = $systemd::dns_stub_listener,
Boolean $use_stub_resolver = $systemd::use_stub_resolver,
){

assert_private()
Expand All @@ -62,9 +67,13 @@
enable => $_enable_resolved,
}

$_resolv_conf_target = $use_stub_resolver ? {
true => '/run/systemd/resolve/stub-resolv.conf',
default => '/run/systemd/resolve/resolv.conf',
}
file { '/etc/resolv.conf':
ensure => 'symlink',
target => '/run/systemd/resolve/resolv.conf',
target => $_resolv_conf_target,
require => Service['systemd-resolved'],
}

Expand Down
12 changes: 7 additions & 5 deletions manifests/service_limits.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
$_content = undef
}

if ($limits and !empty($limits)) and $source {
fail('You may not supply both limits and source parameters to systemd::service_limits')
}
elsif ($limits == undef or empty($limits)) and ($source == undef) {
fail('You must supply either the limits or source parameter to systemd::service_limits')
if $ensure != 'absent' {
if ($limits and !empty($limits)) and $source {
fail('You may not supply both limits and source parameters to systemd::service_limits')
}
elsif ($limits == undef or empty($limits)) and ($source == undef) {
fail('You must supply either the limits or source parameter to systemd::service_limits')
}
}

systemd::dropin_file { "${name}-90-limits.conf":
Expand Down
2 changes: 1 addition & 1 deletion manifests/systemctl/daemon_reload.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
exec { 'systemctl-daemon-reload':
command => 'systemctl daemon-reload',
refreshonly => true,
path => $::path,
path => $facts['path'],
}
}
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camptocamp-systemd",
"version": "2.0.0",
"version": "2.1.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand All @@ -10,7 +10,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 5.0.0"
"version_requirement": ">= 4.13.1 < 6.0.0"
}
],
"requirements": [
Expand Down
122 changes: 71 additions & 51 deletions spec/defines/service_limits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,78 @@

let(:title) { 'test.service' }

let(:params) {{
:limits => {
'LimitCPU' => '10m',
'LimitFSIZE' => 'infinity',
'LimitDATA' => '10K',
'LimitNOFILE' => 20,
'LimitNICE' => '-10',
'LimitRTPRIO' => 50,
'IODeviceWeight' => [
{'/dev/weight' => 10},
{'/dev/weight2' => 20}
],
'IOReadBandwidthMax' => [
{'/bw/max' => '10K'}
]
}
}}
describe 'with limits and present' do
let(:params) {{
:limits => {
'LimitCPU' => '10m',
'LimitFSIZE' => 'infinity',
'LimitDATA' => '10K',
'LimitNOFILE' => '20:infinity',
'LimitNICE' => '-10',
'LimitRTPRIO' => 50,
'IODeviceWeight' => [
{'/dev/weight' => 10},
{'/dev/weight2' => 20}
],
'IOReadBandwidthMax' => [
{'/bw/max' => '10K'}
]
}
}}

it { is_expected.to compile.with_all_deps }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:ensure => 'file',
:content => /LimitCPU=10m/,
:mode => '0444'
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitFSIZE=infinity/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitDATA=10K/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitNOFILE=20/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitNICE=-10/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitRTPRIO=50/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IODeviceWeight=/dev/weight 10)
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IODeviceWeight=/dev/weight2 20)
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IOReadBandwidthMax=/bw/max 10K)
) }
it { is_expected.to create_exec("restart #{title} because limits").with(
:command => "systemctl restart #{title}",
:refreshonly => true
) }
it { is_expected.to compile.with_all_deps }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:ensure => 'file',
:content => /LimitCPU=10m/,
:mode => '0444'
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitFSIZE=infinity/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitDATA=10K/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitNOFILE=20:infinity/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitNICE=-10/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => /LimitRTPRIO=50/
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IODeviceWeight=/dev/weight 10)
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IODeviceWeight=/dev/weight2 20)
) }
it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
:content => %r(IOReadBandwidthMax=/bw/max 10K)
) }
it { is_expected.to create_exec("restart #{title} because limits").with(
:command => "systemctl restart #{title}",
:refreshonly => true
) }
end

describe 'ensured absent' do
let(:params) {{
:ensure => 'absent',
}}

it { is_expected.to compile.with_all_deps }
it do
is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf")
.with_ensure('absent')
.that_notifies("Exec[restart #{title} because limits]")
end
it do
is_expected.to create_exec("restart #{title} because limits")
.with_command("systemctl restart #{title}")
.with_refreshonly(true)
end
end
end
end
end
Expand Down
Loading