Showing with 94 additions and 55 deletions.
  1. +0 −6 .travis.yml
  2. +23 −2 CHANGELOG.md
  3. +0 −1 Gemfile
  4. +2 −2 README.md
  5. +1 −1 lib/facter/systemd.rb
  6. +7 −8 manifests/dropin_file.pp
  7. +5 −7 manifests/init.pp
  8. +3 −3 manifests/timesyncd.pp
  9. +1 −1 metadata.json
  10. +23 −3 spec/classes/init_spec.rb
  11. +29 −0 spec/defines/dropin_file_spec.rb
  12. +0 −21 spec/spec_helper.rb
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
---
language: ruby
sudo: false
addons:
apt:
packages:
- libaugeas-dev
sources:
- augeas
cache: bundler
bundler_args: --without system_tests
script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'"]
Expand Down
25 changes: 23 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# Changelog


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

## [1.1.0](https://github.com/camptocamp/puppet-systemd/tree/1.1.0) (2017-10-17)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/1.1.0...1.1.1)

**Fixed bugs:**

- fact systemd\_internal\_services is empty [\#47](https://github.com/camptocamp/puppet-systemd/issues/47)
- Use the correct type on $service\_limits [\#52](https://github.com/camptocamp/puppet-systemd/pull/52) ([ekohl](https://github.com/ekohl))
- Fix issue \#47 [\#48](https://github.com/camptocamp/puppet-systemd/pull/48) ([axxelG](https://github.com/axxelG))

**Closed issues:**

- Not able to set limits via systemd class [\#49](https://github.com/camptocamp/puppet-systemd/issues/49)

**Merged pull requests:**

- Clean up test tooling [\#54](https://github.com/camptocamp/puppet-systemd/pull/54) ([ekohl](https://github.com/ekohl))
- Correct parameter documentation [\#53](https://github.com/camptocamp/puppet-systemd/pull/53) ([ekohl](https://github.com/ekohl))
- Use a space-separated in timesyncd.conf [\#50](https://github.com/camptocamp/puppet-systemd/pull/50) ([hfm](https://github.com/hfm))
- Use the same systemd drop-in file for different units [\#46](https://github.com/camptocamp/puppet-systemd/pull/46) ([countsudoku](https://github.com/countsudoku))
- release 1.1.0 [\#44](https://github.com/camptocamp/puppet-systemd/pull/44) ([bastelfreak](https://github.com/bastelfreak))

## [1.1.0](https://github.com/camptocamp/puppet-systemd/tree/1.1.0) (2017-10-24)

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

Expand Down Expand Up @@ -128,4 +149,4 @@



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ 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 'ruby-augeas', :require => false
gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1\./
gem 'json_pure', '< 2.0.2', :require => false
end
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ It is possible to configure the default ntp servers in /etc/systemd/timesyncd.co
```puppet
class{'::systemd':
$manage_timesyncd => true,
$ntp_server => '0.pool.ntp.org,1.pool.ntp.org',
$fallback_ntp_server => '2.pool.ntp.org,3.pool.ntp.org',
$ntp_server => ['0.pool.ntp.org', '1.pool.ntp.org'],
$fallback_ntp_server => ['2.pool.ntp.org', '3.pool.ntp.org'],
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
)
lines = command_output.lines.lazy.map { |line| line.split(/\s+/) }
lines.each_with_object({}) do |(service, status, *), result|
result[service] = status.to_sym
result[service] = status
end
end
end
15 changes: 7 additions & 8 deletions manifests/dropin_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@
#
define systemd::dropin_file(
Systemd::Unit $unit,
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,
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,
) {
include ::systemd

assert_type(Systemd::Dropin, $name)

if $target {
$_ensure = 'link'
} else {
Expand All @@ -56,7 +55,7 @@
})
}

file { "${path}/${unit}.d/${name}":
file { "${path}/${unit}.d/${filename}":
ensure => $_ensure,
content => $content,
source => $source,
Expand Down
12 changes: 5 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# @param timesyncd_ensure
# The state that the ``timesyncd`` service should be in
#
# @param $ntp_server
# @param ntp_server
# comma separated list of ntp servers, will be combined with interface specific
# addresses from systemd-networkd. requires puppetlabs-inifile
#
Expand All @@ -33,22 +33,20 @@
# as the fallback NTP servers. Any per-interface NTP servers obtained from
# systemd-networkd take precedence over this setting. requires puppetlabs-inifile
class systemd (
Optional[Systemd::ServiceLimits] $service_limits = undef,
Hash[String, Hash[String, Any]] $service_limits = {},
Boolean $manage_resolved = false,
Enum['stopped','running'] $resolved_ensure = 'running',
Boolean $manage_networkd = false,
Enum['stopped','running'] $networkd_ensure = 'running',
Boolean $manage_timesyncd = false,
Enum['stopped','running'] $timesyncd_ensure = 'running',
Optional[String] $ntp_server = undef,
Optional[String] $fallback_ntp_server = undef,
Optional[Variant[Array,String]] $ntp_server = undef,
Optional[Variant[Array,String]] $fallback_ntp_server = undef,
){

contain ::systemd::systemctl::daemon_reload

if $service_limits {
create_resources('systemd::service_limits', $service_limits)
}
create_resources('systemd::service_limits', $service_limits)

if $manage_resolved and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-resolved.service'] {
contain ::systemd::resolved
Expand Down
6 changes: 3 additions & 3 deletions manifests/timesyncd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The state that the ``networkd`` service should be in
#
# @param $ntp_server
# comma separated list of ntp servers, will be combined with interface specific
# A space-separated list of NTP servers, will be combined with interface specific
# addresses from systemd-networkd. requires puppetlabs-inifile
#
# @param fallback_ntp_server
Expand Down Expand Up @@ -36,7 +36,7 @@
if $ntp_server =~ String {
$_ntp_server = $ntp_server
} else {
$_ntp_server = join($ntp_server, ',')
$_ntp_server = join($ntp_server, ' ')
}
ini_setting{'ntp_server':
ensure => 'present',
Expand All @@ -52,7 +52,7 @@
if $fallback_ntp_server =~ String {
$_fallback_ntp_server = $fallback_ntp_server
} else {
$_fallback_ntp_server = join($fallback_ntp_server, ',')
$_fallback_ntp_server = join($fallback_ntp_server, ' ')
}
ini_setting{'fallback_ntp_server':
ensure => 'present',
Expand Down
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": "1.1.0",
"version": "1.1.1",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down
26 changes: 23 additions & 3 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,36 @@
it { is_expected.not_to create_service('systemd-networkd').with_enable(true) }
end

context 'when enabling timesyncd with NTP values' do
context 'when enabling timesyncd with NTP values (string)' do
let(:params) {{
:manage_timesyncd => true,
:ntp_server => '0.pool.ntp.org,1.pool.ntp.org',
:fallback_ntp_server => '2.pool.ntp.org,3.pool.ntp.org'
:ntp_server => '0.pool.ntp.org 1.pool.ntp.org',
:fallback_ntp_server => '2.pool.ntp.org 3.pool.ntp.org'
}}
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_ini_setting('ntp_server')}
it { is_expected.to contain_ini_setting('fallback_ntp_server')}
end

context 'when enabling timesyncd with NTP values (array)' do
let(:params) {{
:manage_timesyncd => true,
:ntp_server => %w(0.pool.ntp.org 1.pool.ntp.org),
:fallback_ntp_server => %w(2.pool.ntp.org 3.pool.ntp.org)
}}
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_ini_setting('ntp_server')}
it { is_expected.to contain_ini_setting('fallback_ntp_server')}
end

context 'when passing service limits' do
let(:params) {{
:service_limits => {'openstack-nova-compute.service' => {'limits' => {'LimitNOFILE' => 32768}}}
}}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__service_limits('openstack-nova-compute.service').with_limits({'LimitNOFILE' => 32768}) }
end
end
end
end
Expand Down
29 changes: 29 additions & 0 deletions spec/defines/dropin_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@
}.to raise_error(/expects a match for Systemd::Dropin/)
}
end

context 'with another drop-in file with the same filename (and content)' do
let(:default_params) {{
:filename => 'longer-timeout.conf',
:content => 'random stuff'
}}
# Create drop-in file longer-timeout.conf for unit httpd.service
let :pre_condition do
"systemd::dropin_file { 'httpd_longer-timeout':
filename => '#{default_params[:filename]}',
unit => 'httpd.service',
content => '#{default_params[:context]}',
}"
end
#
# Create drop-in file longer-timeout.conf for unit ftp.service
let (:title) {'ftp_longer-timeout'}
let :params do
default_params.merge({
:unit => 'ftp.service'
})
end

it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{params[:filename]}").with(
:ensure => 'file',
:content => /#{params[:content]}/,
:mode => '0444'
) }
end
end
end
end
Expand Down
21 changes: 0 additions & 21 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,3 @@
PuppetlabsSpec::Files.cleanup
end
end

require 'pathname'
dir = Pathname.new(__FILE__).parent
Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules')

# There's no real need to make this version dependent, but it helps find
# regressions in Puppet
#
# 1. Workaround for issue #16277 where default settings aren't initialised from
# a spec and so the libdir is never initialised (3.0.x)
# 2. Workaround for 2.7.20 that now only loads types for the current node
# environment (#13858) so Puppet[:modulepath] seems to get ignored
# 3. Workaround for 3.5 where context hasn't been configured yet,
# ticket https://tickets.puppetlabs.com/browse/MODULES-823
#
ver = Gem::Version.new(Puppet.version.split('-').first)
if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0")
puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading"
# libdir is only a single dir, so it can only workaround loading of one external module
Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib"
end