From f14ab8a15c76c72c2a8cb92cdd8d79bae613e6ca Mon Sep 17 00:00:00 2001 From: Jonathan Thurman Date: Wed, 14 Nov 2012 11:43:57 -0800 Subject: Create spec tests for all classes/defines and perform most cleanup recommended by puppet-lint --- manifests/client.pp | 22 ++++++++++++++++++++++ manifests/config.pp | 38 +++++++++++++++++++++++++------------- manifests/database.pp | 28 ++++++++++++++++++++++++++-- manifests/imfile.pp | 23 +++++++++++++++++++++++ manifests/init.pp | 16 +++++++++++++++- manifests/install.pp | 14 +++++++++++++- manifests/params.pp | 12 ++++++++++++ manifests/server.pp | 43 ++++++++++++++++++++++++++++++++----------- manifests/service.pp | 16 ++++++++++++++-- manifests/snippet.pp | 17 +++++++++++++++++ 10 files changed, 199 insertions(+), 30 deletions(-) (limited to 'manifests') diff --git a/manifests/client.pp b/manifests/client.pp index fd76f1e..74f839a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -1,3 +1,25 @@ +# == Class: rsyslog::client +# +# Full description of class role here. +# +# === Parameters +# +# [*sample_parameter*] +# [*log_remote*] +# [*spool_size*] +# [*remote_type*] +# [*log_local*] +# [*log_auth_local*] +# [*custom_config*] +# [*server*] +# [*port*] +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::client': } +# class rsyslog::client ( $log_remote = true, $spool_size = '1g', diff --git a/manifests/config.pp b/manifests/config.pp index aa06535..cbafe61 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,37 +1,49 @@ -class rsyslog::config { +# == Class: rsyslog::config +# +# Full description of class role here. +# +# === Parameters +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::config': } +# +class rsyslog::config inherits rsyslog::params { file { $rsyslog::params::rsyslog_d: + ensure => directory, owner => root, group => $rsyslog::params::run_group, purge => true, recurse => true, force => true, - require => Class["rsyslog::install"], - ensure => directory, + require => Class['rsyslog::install'], } file { $rsyslog::params::rsyslog_conf: + ensure => file, owner => root, group => $rsyslog::params::run_group, - ensure => file, content => template("${module_name}/rsyslog.conf.erb"), - require => Class["rsyslog::install"], - notify => Class["rsyslog::service"], + require => Class['rsyslog::install'], + notify => Class['rsyslog::service'], } file { $rsyslog::params::rsyslog_default: + ensure => file, owner => root, group => $rsyslog::params::run_group, - ensure => file, - source => "puppet:///modules/rsyslog/rsyslog_default", - require => Class["rsyslog::install"], - notify => Class["rsyslog::service"], + source => 'puppet:///modules/rsyslog/rsyslog_default', + require => Class['rsyslog::install'], + notify => Class['rsyslog::service'], } file { $rsyslog::params::spool_dir: + ensure => directory, owner => root, group => $rsyslog::params::run_group, - ensure => directory, - require => Class["rsyslog::install"], - notify => Class["rsyslog::service"], + require => Class['rsyslog::install'], + notify => Class['rsyslog::service'], } } diff --git a/manifests/database.pp b/manifests/database.pp index 183c870..c0112be 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -1,3 +1,27 @@ +# == Class: rsyslog::database +# +# Full description of class role here. +# +# === Parameters +# +# [*backend*] - Which backend server to use (mysql|pgsql) +# [*server*] - Server hostname +# [*database*] - Database name +# [*username*] - Database username +# [*password*] - Database password +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::database': +# backend => 'mysql', +# server => 'localhost', +# database => 'mydb', +# username => 'myuser', +# password => 'mypass', +# } +# class rsyslog::database ( $backend, $server, @@ -8,13 +32,13 @@ class rsyslog::database ( $db_module = "om${backend}" $db_conf = "${rsyslog::params::rsyslog_d}${backend}.conf" - + case $backend { mysql: { $db_package = $rsyslog::params::mysql_package_name } pgsql: { $db_package = $rsyslog::params::pgsql_package_name } default: { fail("Unsupported backend: ${backend}. Only MySQL (mysql) and PostgreSQL (pgsql) are supported.") } } - + package { $db_package: ensure => $rsyslog::params::package_status, before => File[$db_conf], diff --git a/manifests/imfile.pp b/manifests/imfile.pp index 64e6e2f..58554a4 100644 --- a/manifests/imfile.pp +++ b/manifests/imfile.pp @@ -1,3 +1,26 @@ +# == Define: rsyslog::imfile +# +# Full description of class role here. +# +# === Parameters +# +# [*file_name*] +# [*file_tag*] +# [*file_facility*] +# [*polling_interval*] +# [*file_severity*] +# [*run_file_monitor*] +# +# === Variables +# +# === Examples +# +# rsyslog::imfile { 'my-imfile': +# file_name => '/some/file', +# file_tag => 'mytag', +# file_facility => 'myfacility', +# } +# define rsyslog::imfile( $file_name, $file_tag, diff --git a/manifests/init.pp b/manifests/init.pp index 80db400..2f9b015 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,3 +1,17 @@ +# == Class: rsyslog +# +# Meta class to install rsyslog with a basic configuration. You probably want rsyslog::client or rsyslog::server +# +# === Parameters +# +# === Variables +# +# === Examples +# +# class { 'rsyslog': } +# class rsyslog { - include rsyslog::params, rsyslog::install, rsyslog::config, rsyslog::service + class { 'rsyslog::install': } + class { 'rsyslog::config': } + class { 'rsyslog::service': } } diff --git a/manifests/install.pp b/manifests/install.pp index e0601bd..d2cdcb6 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,4 +1,16 @@ -class rsyslog::install { +# == Class: rsyslog::install +# +# This class makes sure that the required packages are installed +# +# === Parameters +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::install': } +# +class rsyslog::install inherits rsyslog::params { package { $rsyslog::params::rsyslog_package_name: ensure => $rsyslog::params::package_status, } diff --git a/manifests/params.pp b/manifests/params.pp index 96c0b27..d5c48b2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,3 +1,15 @@ +# == Class: rsyslog::params +# +# This defines default configuration values for rsyslog. You don't want to use it directly. +# +# === Parameters +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::params': } +# class rsyslog::params { case $::osfamily { debian: { diff --git a/manifests/server.pp b/manifests/server.pp index acdc7db..70c22c9 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -1,3 +1,22 @@ +# == Class: rsyslog::server +# +# This class configures rsyslog for a server role. +# +# === Parameters +# +# [*enable_tcp*] +# [*enable_udp*] +# [*enable_onfile*] +# [*server_dir*] +# [*custom_config*] +# [*high_precision_timestamps*] +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::server': } +# class rsyslog::server ( $enable_tcp = true, $enable_udp = true, @@ -7,15 +26,17 @@ class rsyslog::server ( $high_precision_timestamps = false ) inherits rsyslog { - file { $rsyslog::params::server_conf: - ensure => present, - owner => root, - group => $rsyslog::params::run_group, - content => $custom_config ? { - '' => template("${module_name}/server.conf.erb"), - default => template($custom_config), - }, - require => Class['rsyslog::config'], - notify => Class['rsyslog::service'], - } + $real_content = $custom_config ? { + '' => template("${module_name}/server.conf.erb"), + default => template($custom_config), + } + + file { $rsyslog::params::server_conf: + ensure => present, + owner => root, + group => $rsyslog::params::run_group, + content => $real_content, + require => Class['rsyslog::config'], + notify => Class['rsyslog::service'], + } } diff --git a/manifests/service.pp b/manifests/service.pp index 66c03dc..94bd603 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,7 +1,19 @@ -class rsyslog::service { +# == Class: rsyslog::service +# +# This class enforces running of the rsyslog service. +# +# === Parameters +# +# === Variables +# +# === Examples +# +# class { 'rsyslog::service': } +# +class rsyslog::service inherits rsyslog::params { service { $rsyslog::params::service_name: ensure => running, enable => true, - require => Class["rsyslog::config"], + require => Class['rsyslog::config'], } } diff --git a/manifests/snippet.pp b/manifests/snippet.pp index d59a829..38e71d4 100644 --- a/manifests/snippet.pp +++ b/manifests/snippet.pp @@ -1,3 +1,20 @@ +# == Define: rsyslog::snippet +# +# This class allows for you to create a rsyslog configuration file with whatever content you pass in. +# +# === Parameters +# +# [*content*] - The actual content to place in the file. +# [*ensure*] - How to enforce the file (default: present) +# +# === Variables +# +# === Examples +# +# rsyslog::snippet { 'my-rsyslog-config': +# content => '', +# } +# define rsyslog::snippet( $content, $ensure = 'present' -- cgit v1.2.3