Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
(SIMP-1839) Add journald module
Browse files Browse the repository at this point in the history
In order to get the systemd journal to pass to rsyslog, it needs to be
configured to pass to syslog. Default is to not.

- SIMPed module
- Wrote more spec tests
- Added a few config options to the defaults
- Added details to metadata.json
- Added CentOS as a supported OS
- Fixed lint errors

SIMP-1839 #comment added journald module

Change-Id: I30ab02a6f6f7d9a359186bee74bb1dc17c082905
  • Loading branch information
Nick Miller authored and nmarkowski committed Nov 4, 2016
1 parent 5d71edc commit 26e4c30
Show file tree
Hide file tree
Showing 22 changed files with 612 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
journald: "#{source_dir}"

23 changes: 15 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
*.log
*~
.DS_Store
spec/fixtures/*
*.tmp
.librarian
pkg/*

.*.sw?
.yardoc
dist
/pkg
/spec/fixtures
/spec/rp_env
!/spec/hieradata/default.yaml
!/spec/fixtures/site.pp
/.rspec_system
/.vagrant
/.bundle
/Gemfile.lock
/vendor
/junit
/log
4 changes: 4 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--log-format="%{path}:%{line}:%{check}:%{KIND}:%{message}"
--relative
--no-class_inherits_from_params_class-check
--no-80chars-check
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format documentation
--color
--fail-fast
43 changes: 37 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
# PE/SIMP versions
# app pup ruby
# 2015.2 4.3 2.1.7
# 2015.3 4.3 2.1.8
# 2016.1 4.4 2.1.9
# 2016.2 4.5 2.1.9
# S6.0.0 4.7 2.1.9
---
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
language: ruby
sudo: true
cache: bundler
before_script:
- bundle
bundler_args: --without development system_tests
before_install: rm Gemfile.lock || true
script:
- bundle exec rake test
notifications:
email: false
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.9
env:
- PUPPET_VERSION=3.8
sudo: false
global:
- STRICT_VARIABLES=yes
- TRUSTED_NODE_DATA=yes
matrix:
- PUPPET_VERSION="~> 4.7.0"
- PUPPET_VERSION="~> 4.5.0"
- PUPPET_VERSION="~> 3.8.0"
- PUPPET_VERSION="~> 4.4.0"
- PUPPET_VERSION="~> 4.3.0"
- PUPPET_VERSION="~> 3.8.0" FUTURE_PARSER=yes
matrix:
fast_finish: true
allow_failures:
- env: PUPPET_VERSION="~> 4.5.0"
- env: PUPPET_VERSION="~> 3.8.0"
- env: PUPPET_VERSION="~> 4.4.0"
- env: PUPPET_VERSION="~> 4.3.0"
- env: PUPPET_VERSION="~> 3.8.0" FUTURE_PARSER=yes
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* Thu Nov 03 2016 Nick Miller <[email protected]> - 0.2.2-0
- SIMPed module
- Wrote more spec tests
- Added a few config options to the defaults
- Added details to metadata.json
- Added CentOS as a supported OS
- Fixed lint errors
92 changes: 92 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
This module has grown over time based on a range of contributions from
people using it. If you follow these contributing guidelines your patch
will likely make it into a release a little quicker.


## Contributing

1. Fork the repo.

2. Run the tests. We only take pull requests with passing tests, and
it's great to know that you have a clean slate.

3. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
or fixing a bug, please add a test.

4. Make the test pass.

5. Push to your fork and submit a pull request.


## Dependencies

The testing and development tools have a bunch of dependencies,
all managed by [Bundler](http://bundler.io/) according to the
[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).

By default the tests use a baseline version of Puppet.

If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:

export PUPPET_VERSION="~> 3.2.0"

Install the dependencies like so...

bundle install

## Syntax and style

The test suite will run [Puppet Lint](http://puppet-lint.com/) and
[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
check various syntax and style things. You can run these locally with:

bundle exec rake lint
bundle exec rake syntax

## Running the unit tests

The unit test suite covers most of the code, as mentioned above please
add tests if you're adding new functionality. If you've not used
[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
about how best to test your new feature. Running the test suite is done
with:

bundle exec rake spec

Note also you can run the syntax, style and unit tests in one go with:

bundle exec rake test

### Automatically run the tests

During development of your puppet module you might want to run your unit
tests a couple of times. You can use the following command to automate
running the unit tests on every change made in the manifests folder.

bundle exec guard

## Integration tests

The unit tests just check the code runs, not that it does exactly what
we want on a real machine. For that we're using
[Beaker](https://github.com/puppetlabs/beaker).

Beaker fires up a new virtual machine (using Vagrant) and runs a series of
simple tests against it after applying the module. You can run our
Beaker tests with:

bundle exec rake acceptance

This will use the host described in `spec/acceptance/nodeset/default.yml`
by default. To run against another host, set the `BEAKER_set` environment
variable to the name of a host described by a `.yml` file in the
`nodeset` directory. For example, to run against CentOS 6.4:

BEAKER_set=centos-64-x64 bundle exec rake acceptance

If you don't want to have to recreate the virtual machine every time you
can use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will
at least need `BEAKER_provision` set to yes (the default). The Vagrantfile
for the created virtual machines will be in `.vagrant/beaker_vagrant_files`.
59 changes: 38 additions & 21 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
# ------------------------------------------------------------------------------
# NOTE: SIMP Puppet rake tasks support ruby 2.0 and ruby 2.1
# ------------------------------------------------------------------------------
gem_sources = ENV.key?('SIMP_GEM_SERVERS') ? ENV['SIMP_GEM_SERVERS'].split(/[, ]+/) : ['https://rubygems.org']

gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : "~> 3.0"
gem 'rake', '~> 10'
gem 'rspec-puppet', '~> 2.0'
gem 'puppetlabs_spec_helper', '>= 0.8.0'
gem 'puppet-lint', '>= 1'
gem 'puppet-lint-unquoted_string-check'
gem 'puppet-lint-empty_string-check'
gem 'puppet-lint-spaceship_operator_without_tag-check'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-undef_in_function-check'
gem 'puppet-lint-leading_zero-check'
gem 'puppet-lint-trailing_comma-check'
gem 'puppet-lint-file_ensure-check'
gem 'puppet-lint-variable_contains_upcase'
gem 'simplecov'
gem 'rspec-puppet-facts'
gem 'metadata-json-lint'
gem 'rspec', '< 3.2.0', {"platforms"=>["ruby_18"]}
gem 'json', '< 2.0', {"platforms"=>["ruby_18"]}
gem 'json_pure', '< 2.0', {"platforms"=>["ruby_18"]}
gem_sources.each { |gem_source| source gem_source }

group :test do
gem "rake"
gem 'puppet', ENV.fetch('PUPPET_VERSION', '~>4')
gem "rspec", '< 3.2.0'
gem "rspec-puppet"
gem "hiera-puppet-helper"
gem "puppetlabs_spec_helper"
gem "metadata-json-lint"
gem "simp-rspec-puppet-facts", ENV.fetch('SIMP_RSPEC_PUPPET_FACTS_VERSION', '~> 1.3')
gem 'simp-rake-helpers', ENV.fetch('SIMP_RAKE_HELPERS_VERSION', '~> 3')
end

group :development do
gem "travis"
gem "travis-lint"
gem "travish"
gem "puppet-blacksmith"
gem "guard-rake"
gem 'pry'
gem 'pry-doc'
gem 'puppet-strings'

# `listen` is a dependency of `guard`
# from `listen` 3.1+, `ruby_dep` requires Ruby version >= 2.2.3, ~> 2.2
gem 'listen', '~> 3.0.6'
end

group :system_tests do
gem 'beaker', :git => 'https://github.com/trevor-vaughan/beaker', :ref => 'BKR-931-2.51.0'
gem 'beaker-rspec'
gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', '~> 1.5')
end
16 changes: 15 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
Copyright (C) 2014 R. Tyler Croy <[email protected]>
pupmod-simp-nfs - A Puppet Module for managing NFS

--

Per Section 105 of the Copyright Act of 1976, these works are not entitled to
domestic copyright protection under US Federal law.

The US Government retains the right to pursue copyright protections outside of
the United States.

The United States Government has unlimited rights in this software and all
derivatives thereof, pursuant to the contracts under which it was developed and
the License under which it falls.

---

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

## Overview

systemd-journald is a system service that collects and stores logging data.
It creates and maintains structured, indexed journals based on logging information
systemd-journald is a system service that collects and stores logging data.
It creates and maintains structured, indexed journals based on logging information
that is received from a variety of sources:

* Kernel log messages, via kmsg
Expand Down Expand Up @@ -41,7 +41,7 @@ that is received from a variety of sources:

## Limitations

This module is only appicable on EL7 machines
This module is only applicable on EL7 machines

## Development

Expand Down
23 changes: 2 additions & 21 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
require 'bundler'
Bundler.require(:rake)
require 'rake/clean'

CLEAN.include('spec/fixtures/', 'doc', 'pkg')
CLOBBER.include('.tmp', '.librarian')

require 'puppetlabs_spec_helper/rake_tasks'

task :default => [:clean, :spec]

PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.send('disable_empty_string_assignment')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]

require 'simp/rake/pupmod/helpers'

Simp::Rake::Pupmod::Helpers.new(File.dirname(__FILE__))
7 changes: 4 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Configure journald.conf
class journald::config {
$merged_options = merge($::journald::params::default_options, $::journald::options)

Expand All @@ -10,14 +11,14 @@
file { '/var/log/journal/':
ensure => $journald_dir,
force => true,
owner => 0,
owner => 'root',
group => 'systemd-journal',
}

file { '/etc/systemd/journald.conf':
ensure => 'file',
owner => 0,
group => 0,
owner => 'root',
group => 'root',
content => template("${module_name}/journald.conf.erb"),
}
}
15 changes: 7 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
#
# === Parameters:
#
# $persist_log:: By default, the journal stores log data in /run/log/journal/.
# Since /run/ is volatile, log data is lost at reboot. To make the
# data persistent, it is sufficient to create /var/log/journal/
# where systemd-journald will then store the data.
# $persist_log:: By default, the journal stores log data in /run/log/journal/.
# Since /run/ is volatile, log data is lost at reboot. To make the
# data persistent, it is sufficient to create /var/log/journal/
# where systemd-journald will then store the data.
#
# $options:: a hash with journald parameters
# $options:: a hash with journald parameters
#
class journald (
$persist_log = $journald::params::persist_log,
$options = undef
) inherits journald::params {
if $::osfamily == 'RedHat' and versioncmp($::operatingsystemrelease, '7.0') >= 0 {
if $::osfamily in ['RedHat','CentOS'] and versioncmp($::operatingsystemrelease, '7.0') >= 0 {
contain ::journald::config
contain ::journald::service

Class['journald::config'] ~>
Class['journald::service']
Class['journald::config'] ~> Class['journald::service']
}
}
7 changes: 5 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Default parameters
class journald::params {
$persist_log = true
$default_options = {
Expand All @@ -10,12 +11,14 @@
'RateLimitBurst' => '10000',
'MaxFileSec' => '1month',
'ForwardToSyslog' => 'yes',
'ForwardToKMsg' => 'yes',
'ForwardToKMsg' => 'no',
'ForwardToConsole' => 'no',
'ForwardToWall' => 'yes',
'TTYPath' => '/dev/console',
'MaxLevelStore' => 'debug',
'MaxLevelSyslog' => 'debug',
'MaxLevelKMsg' => 'notice',
'MaxLevelKMsg' => 'err',
'MaxLevelConsole' => 'info',
'MaxLevelWall' => 'emerg',
}
}
3 changes: 2 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# manage the systemd-journald service
class journald::service {
service { ['systemd-journald']:
service { 'systemd-journald':
ensure => running,
enable => true,
}
Expand Down
Loading

0 comments on commit 26e4c30

Please sign in to comment.