4 changes: 4 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixtures:
symlinks:
systemd: "#{source_dir}"
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
language: ruby
sudo: false
addons:
apt:
packages:
- libaugeas-dev
cache: bundler
bundler_args: --without system_tests
script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'", "bundle exec rake metadata"]
script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'"]
matrix:
fast_finish: true
include:
Expand All @@ -15,7 +19,7 @@ matrix:
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.6
- rvm: 2.1.7
env: PUPPET_GEM_VERSION="~> 4.0"
notifications:
email: false
Expand All @@ -29,4 +33,4 @@ deploy:
# all_branches is required to use tags
all_branches: true
# Only publish if our main Ruby target builds
rvm: 1.9.3
rvm: 2.1.7
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# 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)

**Implemented enhancements:**

- Shortcut for creating unit files / tmpfiles [\#4](https://github.com/camptocamp/puppet-systemd/pull/4) ([felixb](https://github.com/felixb))
- Add systemd facts [\#6](https://github.com/camptocamp/puppet-systemd/pull/6) ([roidelapluie](https://github.com/roidelapluie))


## [0.2.2](https://forge.puppetlabs.com/camptocamp/systemd/0.2.2) (2015-08-25)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.1...0.2.2)

**Implemented enhancements:**

- Add 'systemd-tmpfiles-create' [\#1](https://github.com/camptocamp/puppet-systemd/pull/1) ([roidelapluie](https://github.com/roidelapluie))


## [0.2.1](https://forge.puppetlabs.com/camptocamp/systemd/0.2.1) (2015-08-21)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.0...0.2.1)

Expand Down Expand Up @@ -56,4 +68,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 Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :unit_tests do
gem 'rake', :require => false
gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1.8/
gem 'rake', ' < 11.0', :require => false if RUBY_VERSION =~ /^1\.8/
gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1\.8/
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'metadata-json-lint', :require => false
Expand All @@ -21,8 +21,8 @@ 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 'github_changelog_generator', :require => false, :git => 'https://github.com/raphink/github-changelog-generator.git', :branch => 'dev/all_patches' if RUBY_VERSION !~ /^1.8/
gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1.8/
gem 'ruby-augeas', :require => false
gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1\./
end

group :system_tests do
Expand Down
14 changes: 13 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# 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)

**Implemented enhancements:**

- Shortcut for creating unit files / tmpfiles [\#4](https://github.com/camptocamp/puppet-systemd/pull/4) ([felixb](https://github.com/felixb))
- Add systemd facts [\#6](https://github.com/camptocamp/puppet-systemd/pull/6) ([roidelapluie](https://github.com/roidelapluie))


## [0.2.2](https://forge.puppetlabs.com/camptocamp/systemd/0.2.2) (2015-08-25)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.1...0.2.2)

**Implemented enhancements:**

- Add 'systemd-tmpfiles-create' [\#1](https://github.com/camptocamp/puppet-systemd/pull/1) ([roidelapluie](https://github.com/roidelapluie))


## [0.2.1](https://forge.puppetlabs.com/camptocamp/systemd/0.2.1) (2015-08-21)
[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.0...0.2.1)

Expand Down Expand Up @@ -56,4 +68,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 Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@

## Overview

This module declares exec resources that you can use when you change systemd units or configuration files.
This module declares exec resources to create global sync points for reloading systemd.

## Examples
## Usage and examples

### systemctl --daemon-reload
There are two ways to use this module.

### unit files

Let this module handle file creation and systemd reloading.

```puppet
::systemd::unit_file { 'foo.service':
source => "puppet:///modules/${module_name}/foo.service",
}
```

Or handle file creation yourself and trigger systemd.

```puppet
include ::systemd
Expand All @@ -23,7 +35,17 @@ file { '/usr/lib/systemd/system/foo.service':
Exec['systemctl-daemon-reload']
```

### systemd-tmpfiles --create
### tmpfiles

Let this module handle file creation and systemd reloading

```puppet
::systemd::tmpfile { 'foo.conf':
source => "puppet:///modules/${module_name}/foo.conf",
}
```

Or handle file creation yourself and trigger systemd.

```puppet
include ::systemd
Expand Down
14 changes: 7 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ end
PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"]

# Publishing tasks
unless RUBY_VERSION =~ /^1\.8/
unless RUBY_VERSION =~ /^1\./
require 'puppet_blacksmith'
require 'puppet_blacksmith/rake_tasks'
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
m = Blacksmith::Modulefile.new
config.future_release = m.version
config.release_url = "https://forge.puppetlabs.com/#{m.author}/#{m.name}/%s"
end
#require 'github_changelog_generator/task'
#GitHubChangelogGenerator::RakeTask.new :changelog do |config|
# m = Blacksmith::Modulefile.new
# config.future_release = m.version
# config.release_url = "https://forge.puppetlabs.com/#{m.author}/#{m.name}/%s"
#end
end
35 changes: 35 additions & 0 deletions lib/facter/systemd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fact: systemd
#
# Purpose:
# Determine whether SystemD is the init system on the node
#
# Resolution:
# Check the name of the process 1 (ps -p 1)
#
# Caveats:
#

# Fact: systemd-version
#
# Purpose:
# Determine the version of systemd installed
#
# Resolution:
# Check the output of systemctl --version
#
# Caveats:
#

Facter.add(:systemd) do
confine :kernel => :linux
setcode do
Facter::Core::Execution.exec('ps -p 1 -o comm=') == 'systemd'
end
end

Facter.add(:systemd_version) do
confine :systemd => true
setcode do
Facter::Core::Execution.exec("systemctl --version | grep 'systemd' | awk '{ print $2 }'")
end
end
20 changes: 20 additions & 0 deletions manifests/tmpfile.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -- Define: systemd::tmpfile
# Creates a tmpfile and reloads systemd
define systemd::tmpfile(
$ensure = file,
$path = '/etc/tmpfiles.d',
$content = undef,
$source = undef,
) {
include ::systemd

file { "${path}/${title}":
ensure => $ensure,
content => $content,
source => $source,
owner => 'root',
group => 'root',
mode => '0444',
notify => Exec['systemd-tmpfiles-create'],
}
}
20 changes: 20 additions & 0 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -- Define: systemd::unit_file
# Creates a unit file and reloads systemd
define systemd::unit_file(
$ensure = file,
$path = '/etc/systemd/system',
$content = undef,
$source = undef,
) {
include ::systemd

file { "${path}/${title}":
ensure => $ensure,
content => $content,
source => $source,
owner => 'root',
group => 'root',
mode => '0444',
notify => Exec['systemctl-daemon-reload'],
}
}
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": "0.2.2",
"version": "0.3.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/centos-5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HOSTS:
centos-5-x64:
default_apply_opts:
order: random
strict_variables:
platform: el-5-x86_64
hypervisor : docker
image: tianon/centos:5.10
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'yum install -y crontabs tar wget which'
CONFIG:
type: aio
log_level: debug
16 changes: 16 additions & 0 deletions spec/acceptance/nodesets/centos-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HOSTS:
centos-6-x64:
default_apply_opts:
order: random
strict_variables:
platform: el-6-x86_64
hypervisor : docker
image: centos:6
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'rm -rf /var/run/network/*'
- 'yum install -y crontabs tar wget'
CONFIG:
type: aio
log_level: debug
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/centos-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HOSTS:
centos-7-x64:
default_apply_opts:
order: random
strict_variables:
platform: el-7-x86_64
hypervisor : docker
image: centos:7
docker_preserve_image: true
docker_cmd: '["/usr/sbin/init"]'
docker_image_commands:
- 'yum install -y crontabs tar wget'
CONFIG:
type: aio
log_level: debug
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/debian-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HOSTS:
debian-6-x64:
default_apply_opts:
order: random
strict_variables:
platform: debian-6-amd64
hypervisor : docker
image: debian/eol:squeeze
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y cron locales-all net-tools wget'
CONFIG:
type: aio
log_level: debug
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/debian-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HOSTS:
debian-7-x64:
default_apply_opts:
order: random
strict_variables:
platform: debian-7-amd64
hypervisor : docker
image: debian:7
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y cron locales-all net-tools wget'
CONFIG:
type: aio
log_level: debug
16 changes: 16 additions & 0 deletions spec/acceptance/nodesets/debian-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HOSTS:
debian-8-x64:
default_apply_opts:
order: random
strict_variables:
platform: debian-8-amd64
hypervisor : docker
image: debian:8
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y cron locales-all net-tools wget'
- 'rm -f /usr/sbin/policy-rc.d'
CONFIG:
type: aio
log_level: debug
16 changes: 16 additions & 0 deletions spec/acceptance/nodesets/ubuntu-12.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HOSTS:
ubuntu-1204-x64:
default_apply_opts:
order: random
strict_variables:
platform: ubuntu-12.04-amd64
hypervisor : docker
image: ubuntu:12.04
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y net-tools wget'
- 'locale-gen en_US.UTF-8'
CONFIG:
type: aio
log_level: debug
Loading