From a37f182e64f95dc90edafe5f9d15dcc00aa054c6 Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Sat, 28 Jan 2017 18:35:52 +0000 Subject: [PATCH] Major update --- .gitignore | 4 +- .travis.yml | 8 +- Gemfile | 8 +- README.md | 122 ++++-------------- Rakefile | 4 +- manifests/config.pp | 8 +- manifests/helper.pp | 26 +++- manifests/init.pp | 36 +++--- manifests/install.pp | 2 +- manifests/mkhomedir.pp | 23 ++-- manifests/mkhomedir/config.pp | 6 +- manifests/mkhomedir/install.pp | 2 +- manifests/params.pp | 2 +- manifests/service.pp | 2 +- metadata.json | 12 +- .../{centos-70-x64.yml => centos-72-x64.yml} | 6 +- spec/acceptance/nodesets/default.yml | 6 +- spec/classes/oddjob_mkhomedir_spec.rb | 2 - spec/classes/oddjob_spec.rb | 2 - spec/spec_helper_acceptance.rb | 10 +- 20 files changed, 119 insertions(+), 172 deletions(-) rename spec/acceptance/nodesets/{centos-70-x64.yml => centos-72-x64.yml} (71%) diff --git a/.gitignore b/.gitignore index 7d67a92..e8e51cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .librarian .tmp .vagrant +.yardoc Gemfile.lock Puppetfile.lock -spec/fixtures +spec/fixtures/manifests +spec/fixtures/modules pkg log coverage diff --git a/.travis.yml b/.travis.yml index 419f8b0..e0d703e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,7 @@ script: "bundle exec rake test" matrix: fast_finish: true include: - - rvm: 2.1.6 + - rvm: 2.2.5 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" notifications: - email: false + email: true diff --git a/Gemfile b/Gemfile index 213abd1..d80139b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development, :test do gem 'rspec-puppet', '>= 2.2.0', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'metadata-json-lint', :require => false - gem 'puppet-lint', '>= 1.1.0', :require => false + gem 'puppet-lint', '>= 2.1.0', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false @@ -23,11 +23,13 @@ group :development, :test do gem 'puppet-lint-file_source_rights-check', :require => false gem 'puppet-lint-alias-check', :require => false gem 'librarian-puppet', :require => false - gem 'beaker', '>= 2.18.2', '< 3.0.0', :require => false - gem 'beaker-rspec', :require => false + gem 'beaker', '>= 3.0.0', :require => false + gem 'beaker-rspec', '>= 6.0.0', :require => false gem 'rspec-puppet-facts', '>= 1.1.1', :require => false gem 'coveralls', :require => false gem 'specinfra', '>= 2.42.1', :require => false + gem 'puppet-strings', :require => false + gem 'beaker-puppet_install_helper', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/README.md b/README.md index 57ec741..e956d47 100644 --- a/README.md +++ b/README.md @@ -9,40 +9,30 @@ Tested with Travis CI #### Table of Contents -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with oddjob](#setup) +1. [Description](#description) +2. [Setup - The basics of getting started with oddjob](#setup) * [What oddjob affects](#what-oddjob-affects) * [Beginning with oddjob](#beginning-with-oddjob) -4. [Usage - Configuration options and additional functionality](#usage) - * [Classes and Defined Types](#classes-and-defined-types) - * [Class: oddjob](#class-oddjob) - * [Class: oddjob::mkhomedir](#class-oddjobmkhomedir) - * [Defined Type: oddjob::helper](#defined-type-oddjobhelper) - * [Examples](#examples) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +3. [Usage - Configuration options and additional functionality](#usage) +4. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 5. [Limitations - OS compatibility, etc.](#limitations) 6. [Development - Guide for contributing to the module](#development) -## Overview +## Description This module manages oddjob, a D-Bus service which performs random tasks. -## Module Description - -This module installs and manages the oddjob D-Bus service and the mkhomedir -oddjob helper. - ## Setup ### What oddjob affects -* The package(s) containing the oddjob software. -* The service controlling the oddjob daemon. -* Configuration for adding oddjob to the D-Bus system bus. +This module installs and manages the oddjob D-Bus service and the mkhomedir +oddjob helper. ### Beginning with oddjob +In the very simplest case, you can just include the following: + ```puppet include ::dbus include ::oddjob @@ -50,54 +40,7 @@ include ::oddjob ## Usage -### Classes and Defined Types - -#### Class: `oddjob` - -**Parameters within `oddjob`:** - -##### `conf_dir` - -The configuration directory for helpers, usually `/etc/oddjob.conf.d`. - -##### `package_name` - -The name of the package to install that provides the oddjob software. - -##### `service_name` - -The name of the service managing the `oddjobd` daemon. - -#### Class: `oddjob::mkhomedir` - -**Parameters within `oddjob::mkhomedir`:** - -##### `package_name` - -The name of the package to install that provides the oddjob mkhomedir helper. - -#### Defined Type: `oddjob::helper` - -**Parameters within `oddjob::helper`:** - -##### `content` - -The contents of the oddjob helper configuration file. - -##### `dbus_content` - -The optional contents of a D-Bus system bus configuration file. - -##### `name` - -The name will be used to construct the filename for the helper configuration -file of the form `${conf_dir}/oddjobd-${name}.conf`. If a D-Bus system bus -configuration file is desired the filename will be of the form -`oddjob-${name}.conf` usually under `/etc/dbus-1/system.d`. - -### Examples - -To install and enable the mkhomedir oddjob helper: +To install the mkhomedir Oddjob job: ```puppet include ::dbus @@ -105,46 +48,33 @@ include ::oddjob include ::oddjob::mkhomedir ``` -It's then necessary to enable the `pam_oddjob_mkhomedir.so` PAM module somehow, -which can require `Class['::oddjob::mkhomedir']` as a dependency. +You will then likely want to configure the PAM stack to utilise this. ## Reference -### Classes - -#### Public Classes - -* [`oddjob`](#class-oddjob): Main class for installing the oddjob software. -* [`oddjob::mkhomedir`](#class-oddjobmkhomedir): Main class for installing the - mkhomedir oddjob helper. - -#### Private Classes - -* `oddjob::config`: Handles oddjob configuration. -* `oddjob::install`: Handles oddjob installation. -* `oddjob::params`: Different configuration data for different systems. -* `oddjob::service`: Handles starting the oddjobd daemon. -* `oddjob::mkhomedir::config`: Handles mkhomedir oddjob helper configuration. -* `oddjob::mkhomedir::install`: Handles mkhomedir oddjob helper installation. - -### Defined Types - -#### Public Defined Types - -* [`oddjob::helper`](#defined-type-oddjobhelper): Installs per-helper - configuration and optionally D-Bus system bus configuration. +The reference documentation is generated with +[puppet-strings](https://github.com/puppetlabs/puppet-strings) and the latest +version of the documentation is hosted at +[https://bodgit.github.io/puppet-oddjob/](https://bodgit.github.io/puppet-oddjob/). ## Limitations -This module has been built on and tested against Puppet 3.0 and higher. +This module has been built on and tested against Puppet 4.4.0 and higher. The module has been tested on: -* RedHat/CentOS Enterprise Linux 6/7 - -Testing on other platforms has been light and cannot be guaranteed. +* RedHat Enterprise Linux 6/7 ## Development +The module has both [rspec-puppet](http://rspec-puppet.com) and +[beaker-rspec](https://github.com/puppetlabs/beaker-rspec) tests. Run them +with: + +``` +$ bundle exec rake test +$ PUPPET_INSTALL_TYPE=agent PUPPET_INSTALL_VERSION=x.y.z bundle exec rake beaker: +``` + Please log issues or pull requests at [github](https://github.com/bodgit/puppet-oddjob). diff --git a/Rakefile b/Rakefile index ba142ba..efd3cbf 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' require 'rake/clean' +require 'metadata-json-lint/rake_task' +require 'puppet-strings/tasks' CLEAN.include('spec/fixtures/manifests', 'spec/fixtures/modules') CLOBBER.include('.tmp', '.librarian', '.vagrant', 'Puppetfile.lock', 'log', 'junit', 'coverage') @@ -23,7 +25,7 @@ task :test => [ 'lint', ] -PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}' +PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' PuppetLint.configuration.ignore_paths = ['pkg/**/*.pp', 'spec/**/*.pp', 'vendor/**/*.pp'] PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.relative = true diff --git a/manifests/config.pp b/manifests/config.pp index 225b078..74bd180 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,8 +1,8 @@ -# +# @!visibility private class oddjob::config { ::dbus::system { 'oddjob': - content => file('oddjob/oddjob.conf'), + content => file("${module_name}/oddjob.conf"), } # FIXME Needed? @@ -18,7 +18,7 @@ owner => 0, group => 0, mode => '0644', - content => file('oddjob/oddjobd.conf'), + content => file("${module_name}/oddjobd.conf"), } file { $::oddjob::conf_dir: @@ -29,6 +29,6 @@ } ::oddjob::helper { 'introspection': - content => file('oddjob/oddjobd-introspection.conf'), + content => file("${module_name}/oddjobd-introspection.conf"), } } diff --git a/manifests/helper.pp b/manifests/helper.pp index 7b4f48d..d2e9fee 100644 --- a/manifests/helper.pp +++ b/manifests/helper.pp @@ -1,23 +1,35 @@ +# Helper to configure Oddjob jobs. # +# @example +# include ::dbus +# include ::oddjob +# ::oddjob::helper { 'mkhomedir': +# content => file('oddjob/oddjobd-mkhomedir.conf'), +# dbus_content => file('oddjob/oddjob-mkhomedir.conf'), +# } +# +# @param content The Oddjob job content. +# @param dbus_content The D-Bus configuration content. +# @param job The name of the Oddjob job. +# +# @see puppet_classes::oddjob ::oddjob define oddjob::helper ( - $content, - $dbus_content = undef, + String $content, + Optional[String] $dbus_content = undef, + String $job = $title, ) { if ! defined(Class['::oddjob']) { fail('You must include the oddjob base class before using any oddjob defined resources') } - validate_string($content) - validate_string($dbus_content) - if $dbus_content { - ::dbus::system { "oddjob-${name}": + ::dbus::system { "oddjob-${job}": content => $dbus_content, } } - file { "${::oddjob::conf_dir}/oddjobd-${name}.conf": + file { "${::oddjob::conf_dir}/oddjobd-${job}.conf": ensure => file, owner => 0, group => 0, diff --git a/manifests/init.pp b/manifests/init.pp index 13bea1d..4d391b3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,22 +1,26 @@ +# Installs and manages Oddjob. # +# @example Declaring the class +# include ::dbus +# include ::oddjob +# +# @param conf_dir Top-level configuration directory, usually +# `/etc/oddjobd.conf.d`. +# @param package_name The name of the package. +# @param service_name The service name. +# +# @see puppet_classes::oddjob::mkhomedir ::oddjob::mkhomedir +# @see puppet_defined_types::oddjob::helper ::oddjob::helper class oddjob ( - $conf_dir = $::oddjob::params::conf_dir, - $package_name = $::oddjob::params::package_name, - $service_name = $::oddjob::params::service_name, + Stdlib::Absolutepath $conf_dir = $::oddjob::params::conf_dir, + String $package_name = $::oddjob::params::package_name, + String $service_name = $::oddjob::params::service_name, ) inherits ::oddjob::params { - validate_absolute_path($conf_dir) - validate_string($package_name) - validate_string($service_name) - - include ::oddjob::install - include ::oddjob::config - include ::oddjob::service - - anchor { 'oddjob::begin': } - anchor { 'oddjob::end': } + contain ::oddjob::install + contain ::oddjob::config + contain ::oddjob::service - Anchor['oddjob::begin'] -> Class['::oddjob::install'] - -> Class['::oddjob::config'] ~> Class['::oddjob::service'] - -> Anchor['oddjob::end'] + Class['::oddjob::install'] -> Class['::oddjob::config'] + ~> Class['::oddjob::service'] } diff --git a/manifests/install.pp b/manifests/install.pp index fb6f20a..d0ca1f4 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,4 +1,4 @@ -# +# @!visibility private class oddjob::install { package { $::oddjob::package_name: diff --git a/manifests/mkhomedir.pp b/manifests/mkhomedir.pp index 58e771d..6e00295 100644 --- a/manifests/mkhomedir.pp +++ b/manifests/mkhomedir.pp @@ -1,20 +1,23 @@ +# Installs the Oddjob mkhomedir job. # +# @example Declaring the class +# include ::dbus +# include ::oddjob +# include ::oddjob::mkhomedir +# +# @param package_name The name of the package. +# +# @see puppet_classes::oddjob ::oddjob class oddjob::mkhomedir ( - $package_name = $::oddjob::params::mkhomedir_package_name, + String $package_name = $::oddjob::params::mkhomedir_package_name, ) inherits ::oddjob::params { if ! defined(Class['::oddjob']) { fail('You must include the oddjob base class before using the oddjob::mkhomedir class') } - validate_string($package_name) - - include ::oddjob::mkhomedir::install - include ::oddjob::mkhomedir::config - - anchor { 'oddjob::mkhomedir::begin': } - anchor { 'oddjob::mkhomedir::end': } + contain ::oddjob::mkhomedir::install + contain ::oddjob::mkhomedir::config - Anchor['oddjob::mkhomedir::begin'] -> Class['::oddjob::mkhomedir::install'] - -> Class['::oddjob::mkhomedir::config'] -> Anchor['oddjob::mkhomedir::end'] + Class['::oddjob::mkhomedir::install'] -> Class['::oddjob::mkhomedir::config'] } diff --git a/manifests/mkhomedir/config.pp b/manifests/mkhomedir/config.pp index 2a5f585..752e767 100644 --- a/manifests/mkhomedir/config.pp +++ b/manifests/mkhomedir/config.pp @@ -1,8 +1,8 @@ -# +# @!visibility private class oddjob::mkhomedir::config { ::oddjob::helper { 'mkhomedir': - content => file('oddjob/oddjobd-mkhomedir.conf'), - dbus_content => file('oddjob/oddjob-mkhomedir.conf'), + content => file("${module_name}/oddjobd-mkhomedir.conf"), + dbus_content => file("${module_name}/oddjob-mkhomedir.conf"), } } diff --git a/manifests/mkhomedir/install.pp b/manifests/mkhomedir/install.pp index 4f8d9eb..3c25314 100644 --- a/manifests/mkhomedir/install.pp +++ b/manifests/mkhomedir/install.pp @@ -1,4 +1,4 @@ -# +# @!visibility private class oddjob::mkhomedir::install { package { $::oddjob::mkhomedir::package_name: diff --git a/manifests/params.pp b/manifests/params.pp index e2452b0..637a0f0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,4 +1,4 @@ -# +# @!visibility private class oddjob::params { case $::osfamily { diff --git a/manifests/service.pp b/manifests/service.pp index c5fbd1d..eb876f0 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,4 +1,4 @@ -# +# @!visibility private class oddjob::service { service { $::oddjob::service_name: diff --git a/metadata.json b/metadata.json index 9926be9..9e91de8 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "bodgit-oddjob", - "version": "1.0.0", + "version": "2.0.0", "author": "bodgit", "summary": "Puppet Module for managing Oddjob", "license": "Apache-2.0", @@ -40,11 +40,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=3.0.0 <5.0.0" - }, - { - "name": "pe", - "version_requirement": ">=3.7.0 <2015.4.0" + "version_requirement": ">=4.4.0 <5.0.0" } ], "tags": [ @@ -55,11 +51,11 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.6.0 <5.0.0" + "version_requirement": ">=4.13.0 <5.0.0" }, { "name": "bodgit/dbus", - "version_requirement": ">=1.1.2 <2.0.0" + "version_requirement": ">=2.0.0 <3.0.0" } ] } diff --git a/spec/acceptance/nodesets/centos-70-x64.yml b/spec/acceptance/nodesets/centos-72-x64.yml similarity index 71% rename from spec/acceptance/nodesets/centos-70-x64.yml rename to spec/acceptance/nodesets/centos-72-x64.yml index 82a6f67..cb54d6f 100644 --- a/spec/acceptance/nodesets/centos-70-x64.yml +++ b/spec/acceptance/nodesets/centos-72-x64.yml @@ -1,10 +1,10 @@ HOSTS: - centos-70-x64: + centos-72-x64: roles: - master platform: el-7-x86_64 - box: puppetlabs/centos-7.0-64-nocm - box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.0-64-nocm + box: puppetlabs/centos-7.2-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.2-64-nocm hypervisor: vagrant CONFIG: type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 82a6f67..cb54d6f 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,10 +1,10 @@ HOSTS: - centos-70-x64: + centos-72-x64: roles: - master platform: el-7-x86_64 - box: puppetlabs/centos-7.0-64-nocm - box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.0-64-nocm + box: puppetlabs/centos-7.2-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.2-64-nocm hypervisor: vagrant CONFIG: type: foss diff --git a/spec/classes/oddjob_mkhomedir_spec.rb b/spec/classes/oddjob_mkhomedir_spec.rb index 9a6d0a6..2255c55 100644 --- a/spec/classes/oddjob_mkhomedir_spec.rb +++ b/spec/classes/oddjob_mkhomedir_spec.rb @@ -31,8 +31,6 @@ super() + ' include ::oddjob' end - it { should contain_anchor('oddjob::mkhomedir::begin') } - it { should contain_anchor('oddjob::mkhomedir::end') } it { should contain_class('oddjob::mkhomedir') } it { should contain_class('oddjob::mkhomedir::config') } it { should contain_class('oddjob::mkhomedir::install') } diff --git a/spec/classes/oddjob_spec.rb b/spec/classes/oddjob_spec.rb index 10403ec..fa4b207 100644 --- a/spec/classes/oddjob_spec.rb +++ b/spec/classes/oddjob_spec.rb @@ -22,8 +22,6 @@ facts end - it { should contain_anchor('oddjob::begin') } - it { should contain_anchor('oddjob::end') } it { should contain_class('oddjob') } it { should contain_class('oddjob::config') } it { should contain_class('oddjob::install') } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 7add696..1807f0d 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,8 +1,12 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' +require 'beaker/puppet_install_helper' hosts.each do |host| - install_puppet + # Just assume the OpenBSD box has Puppet installed already + if host['platform'] !~ /^openbsd-/i + run_puppet_install_helper_on(host) + end end RSpec.configure do |c| @@ -13,8 +17,8 @@ c.before :suite do hosts.each do |host| puppet_module_install(:source => proj_root, :module_name => 'oddjob') - on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','install','bodgit-dbus'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'bodgit-dbus'), { :acceptable_exit_codes => [0,1] } end end end