Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanups and fixes #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This module will manage the pattern databases of *syslog-ng* by using existing f

Depending on the top-level configuration variables `$base_dir` and `$temp_dir`, this module will manage and execute the following elements in order:

0. (OPTIONAL) Manage package `syslog-ng`
0. (OPTIONAL) Manage package `syslog-ng` and remove the default syslog daemon (usually rsyslog)
1. Manage `$base_dir/etc/syslog-ng/patterndb.d` recursively
2. Manage the contents of the above directory using [existing](#defined-type-patterndbrawruleset) or [generated](#defined-type-patterndbsimpleruleset) patterndb *ruleset* files
3. Merge the contents of the latter using `pdbtool` into a temporary file `${temp_dir}/syslog-ng/patterndb/${parser}.xml` where `$parser` is the name of the *patterndb* (you can have as many as you want, *e.g.* for *staged parsing*.
Expand Down
11 changes: 2 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@
validate_array($syslogng_modules)
# package
if $manage_package {
if is_string($package_name) {
$real_package_name = $package_name
} else {
case $::osfamily {
'RedHat': { $real_package_name = 'syslog-ng' }
'Debian': { $real_package_name = 'syslog-ng' }
default: { fail("unsupported osfamily: ${::osfamily}") }
}
class { '::patterndb::install':
package_name => $package_name,
}
ensure_resource ( 'package', $real_package_name, { 'ensure' => 'installed' })
}
ensure_resource ( 'file', $temp_dir, { ensure => directory } )
ensure_resource ( 'file', "${base_dir}/etc", { ensure => 'directory' } )
Expand Down
24 changes: 24 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# == Class: patterndb::install
#
# Ensure that the default syslog is uninstalled and that syslog-ng is installed.
#
class patterndb::install (
$package_name
) inherits patterndb::params
{
if is_string($package_name) {
$real_package_name = $package_name
} else {
$real_package_name = $::patterndb::params::syslog_ng_package_name
}

package { $::patterndb::params::default_syslog_package_name:
ensure => absent,
}

package { $real_package_name:
ensure => installed,
require => Package[$::patterndb::params::default_syslog_package_name],
}
}
21 changes: 21 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# == Class: patterndb::params
#
# Defines some variables based on the operating system
#
class patterndb::params {

case $::osfamily {
'RedHat': {
$syslog_ng_package_name = 'syslog-ng'
$default_syslog_package_name = 'rsyslog'
}
'Debian': {
$syslog_ng_package_name = 'syslog-ng'
$default_syslog_package_name = 'rsyslog'
}
default: {
fail("Unsupported operating system ${::osfamily}")
}
}
}
4 changes: 2 additions & 2 deletions manifests/parser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
$syslogng_modules = $::patterndb::syslogng_modules
) {
if ! defined(Class['Patterndb']) {
include patterndb
include ::patterndb
}
if empty($syslogng_modules) {
$modules = ''
$modules = undef
} else {
$tmp = join($syslogng_modules,' --module=')
$modules = "--module=${tmp}"
Expand Down
2 changes: 1 addition & 1 deletion manifests/raw/ruleset.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
validate_bool($recurse)

if ! defined(Class['Patterndb']) {
include patterndb
include ::patterndb
}

if ! defined(Patterndb::Parser[$parser]) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/simple/ruleset.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
) {

if ! defined(Class['Patterndb']) {
include patterndb
include ::patterndb
}

$patterns_a = string2array($patterns)
Expand Down
2 changes: 1 addition & 1 deletion smoke/NOK_mismatching_action.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_getent.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/',
syslogng_modules => [ 'tfgetent' ]
}
Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_hybrid.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_modules.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/',
syslogng_modules => [ 'basicfuncs' ]
}
Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_multiple_pdb.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_notest.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/',
syslogng_modules => [ 'pdbtool_test_would_fail_with_this_module' ],
test_before_deploy => false
Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_raw.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/',
syslogng_modules => ['tfgetent']
}
Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_s.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_separate_action.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_separate_rules.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_separate_rules_and_actions.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_simple.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_simple_action.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_simple_coerce.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_simple_context.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_simple_empty.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp/'
}

Expand Down
2 changes: 1 addition & 1 deletion smoke/OK_yum.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
class { 'patterndb':
class { '::patterndb':
base_dir => '/tmp',
syslogng_modules => [ 'tfgeoip', 'tfgetent' ],
test_before_deploy => true,
Expand Down