diff --git a/data/default.yaml b/data/default.yaml index 91348fd..a72a3e9 100644 --- a/data/default.yaml +++ b/data/default.yaml @@ -9,3 +9,4 @@ patterndb::_manage_top_dirs: true patterndb::test_before_deploy: &test_before_deploy true patterndb::parser::test_before_deploy: *test_before_deploy patterndb::config_dir: /etc/syslog-ng/patterndb.d +patterndb::var_dir: /var/lib/syslog-ng diff --git a/data/osfamily/FreeBSD.yaml b/data/osfamily/FreeBSD.yaml index b4b0ef7..ec4f07d 100644 --- a/data/osfamily/FreeBSD.yaml +++ b/data/osfamily/FreeBSD.yaml @@ -1,2 +1,3 @@ --- patterndb::config_dir: /usr/local/etc/patterndb.d +patterndb::var_dir: /var/syslog-ng diff --git a/examples/NOK_mismatching_action.pp b/examples/NOK_mismatching_action.pp index dcac8d7..4c5bef7 100644 --- a/examples/NOK_mismatching_action.pp +++ b/examples/NOK_mismatching_action.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } Exec { diff --git a/examples/OK_getent.pp b/examples/OK_getent.pp index d4f0ebb..5269ba7 100644 --- a/examples/OK_getent.pp +++ b/examples/OK_getent.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', syslogng_modules => ['tfgetent'], } diff --git a/examples/OK_hiera.pp b/examples/OK_hiera.pp index 0b4fbcd..0b847d0 100644 --- a/examples/OK_hiera.pp +++ b/examples/OK_hiera.pp @@ -1,6 +1,5 @@ # class { 'patterndb': - base_dir => '/tmp/', manage_package => false, syslogng_modules => [], use_hiera => true, diff --git a/examples/OK_hiera_puppet5.pp b/examples/OK_hiera_puppet5.pp index 132679d..90368ee 100644 --- a/examples/OK_hiera_puppet5.pp +++ b/examples/OK_hiera_puppet5.pp @@ -1,6 +1,5 @@ # class { 'patterndb': - base_dir => '/tmp/', manage_package => false, syslogng_modules => [], use_hiera => true, diff --git a/examples/OK_hybrid.pp b/examples/OK_hybrid.pp index 8629feb..9705ae3 100644 --- a/examples/OK_hybrid.pp +++ b/examples/OK_hybrid.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::raw::ruleset { 'raw': diff --git a/examples/OK_ltgt.pp b/examples/OK_ltgt.pp index 5835b16..0603c34 100644 --- a/examples/OK_ltgt.pp +++ b/examples/OK_ltgt.pp @@ -1,6 +1,5 @@ # class { 'patterndb': - base_dir => '/tmp/', manage_package => false, syslogng_modules => [], } diff --git a/examples/OK_modules.pp b/examples/OK_modules.pp index c6dac52..c0cbe42 100644 --- a/examples/OK_modules.pp +++ b/examples/OK_modules.pp @@ -4,7 +4,6 @@ } class { 'patterndb': manage_package => false, - base_dir => '/tmp/', syslogng_modules => ['basicfuncs'], } diff --git a/examples/OK_multiple_pdb.pp b/examples/OK_multiple_pdb.pp index a0994de..91be537 100644 --- a/examples/OK_multiple_pdb.pp +++ b/examples/OK_multiple_pdb.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'dhclient': diff --git a/examples/OK_notest.pp b/examples/OK_notest.pp index a9d027a..c297cb5 100644 --- a/examples/OK_notest.pp +++ b/examples/OK_notest.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', syslogng_modules => ['pdbtool_test_would_fail_with_this_module'], test_before_deploy => false, } diff --git a/examples/OK_raw.pp b/examples/OK_raw.pp index 0177e28..98ac7ef 100644 --- a/examples/OK_raw.pp +++ b/examples/OK_raw.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', syslogng_modules => [], } diff --git a/examples/OK_s.pp b/examples/OK_s.pp index 37a2b42..4ec1012 100644 --- a/examples/OK_s.pp +++ b/examples/OK_s.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } Patterndb::Simple::Rule { diff --git a/examples/OK_separate_action.pp b/examples/OK_separate_action.pp index b5ef392..c886875 100644 --- a/examples/OK_separate_action.pp +++ b/examples/OK_separate_action.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } Exec { diff --git a/examples/OK_separate_rules.pp b/examples/OK_separate_rules.pp index 489ce27..2677fb8 100644 --- a/examples/OK_separate_rules.pp +++ b/examples/OK_separate_rules.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'empty_ruleset': diff --git a/examples/OK_separate_rules_and_actions.pp b/examples/OK_separate_rules_and_actions.pp index f8d396b..8f7f243 100644 --- a/examples/OK_separate_rules_and_actions.pp +++ b/examples/OK_separate_rules_and_actions.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } Exec { diff --git a/examples/OK_simple.pp b/examples/OK_simple.pp index 5ee33d0..9df1a42 100644 --- a/examples/OK_simple.pp +++ b/examples/OK_simple.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'dhclient': diff --git a/examples/OK_simple_action.pp b/examples/OK_simple_action.pp index a429061..70f4c64 100644 --- a/examples/OK_simple_action.pp +++ b/examples/OK_simple_action.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'dhclient': diff --git a/examples/OK_simple_coerce.pp b/examples/OK_simple_coerce.pp index 806af69..1cd304e 100644 --- a/examples/OK_simple_coerce.pp +++ b/examples/OK_simple_coerce.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'plop': diff --git a/examples/OK_simple_context.pp b/examples/OK_simple_context.pp index 69bfc58..471b4ab 100644 --- a/examples/OK_simple_context.pp +++ b/examples/OK_simple_context.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'dhclient': diff --git a/examples/OK_simple_empty.pp b/examples/OK_simple_empty.pp index 0d9f939..9433d61 100644 --- a/examples/OK_simple_empty.pp +++ b/examples/OK_simple_empty.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp/', } patterndb::simple::ruleset { 'empty': diff --git a/examples/OK_yum.pp b/examples/OK_yum.pp index baf9495..b0b3a35 100644 --- a/examples/OK_yum.pp +++ b/examples/OK_yum.pp @@ -1,7 +1,6 @@ # class { 'patterndb': manage_package => false, - base_dir => '/tmp', syslogng_modules => [], test_before_deploy => true, } diff --git a/manifests/init.pp b/manifests/init.pp index d439f86..3d41364 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,8 +2,8 @@ class patterndb ( String[1] $package_name, Stdlib::Absolutepath $config_dir, + Stdlib::Absolutepath $var_dir, Stdlib::Absolutepath $cache_dir = '/var/cache/syslog-ng', - String[1] $base_dir = '/', Boolean $manage_package = true, Array[String[1]] $syslogng_modules = [], Boolean $use_hiera = false, @@ -15,17 +15,15 @@ } ensure_resource ( 'file', $cache_dir, { ensure => directory }) ensure_resource ( - 'file', "${base_dir}/var/lib/syslog-ng", + 'file', $var_dir, { ensure => 'directory' } ) - ensure_resource ( - 'file', "${base_dir}/var/lib/syslog-ng/patterndb", - { - ensure => 'directory', - purge => true, - recurse => true - } - ) + file { "${var_dir}/patterndb": + ensure => 'directory', + purge => true, + recurse => true, + } + file { $config_dir: ensure => directory, purge => true, diff --git a/manifests/parser.pp b/manifests/parser.pp index af2261f..dde73b9 100644 --- a/manifests/parser.pp +++ b/manifests/parser.pp @@ -26,7 +26,7 @@ }) ensure_resource ('file', "patterndb::file::${name}", { 'ensure' => 'present', - 'path' => "${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml" + 'path' => "${patterndb::var_dir}/patterndb/${name}.xml" }) exec { "patterndb::merge::${name}": command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::config_dir}/${name} -p ${patterndb::cache_dir}/patterndb/${name}.xml", @@ -44,7 +44,7 @@ } exec { "patterndb::deploy::${name}": - command => "cp ${patterndb::cache_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/", + command => "cp ${patterndb::cache_dir}/patterndb/${name}.xml ${patterndb::var_dir}/patterndb/", logoutput => true, path => $facts['path'], refreshonly => true, diff --git a/spec/defines/raw_ruleset_spec.rb b/spec/defines/raw_ruleset_spec.rb index f2ea1cb..0cab2b2 100644 --- a/spec/defines/raw_ruleset_spec.rb +++ b/spec/defines/raw_ruleset_spec.rb @@ -13,7 +13,7 @@ 'myrawruleset' end let :pre_condition do - 'class { "patterndb": base_dir => "BASEDIR", }' + 'class { "patterndb": }' end context 'Raw ruleset with no params' do @@ -33,9 +33,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_file('BASEDIR/usr/local/etc/patterndb.d/default/myrawruleset.pdb') } + it { is_expected.to contain_file('/usr/local/etc/patterndb.d/default/myrawruleset.pdb') } else - it { is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb') } + it { is_expected.to contain_file('/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb') } end end @@ -49,9 +49,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_file('BASEDIR/usr/local/etc/patterndb.d/default/myrawruleset').with(ensure: 'directory') } + it { is_expected.to contain_file('/usr/local/etc/patterndb.d/default/myrawruleset').with(ensure: 'directory') } else - it { is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset').with(ensure: 'directory') } + it { is_expected.to contain_file('/etc/syslog-ng/patterndb.d/default/myrawruleset').with(ensure: 'directory') } end end end diff --git a/spec/defines/simple_action_spec.rb b/spec/defines/simple_action_spec.rb index 7a5ab10..6a65606 100644 --- a/spec/defines/simple_action_spec.rb +++ b/spec/defines/simple_action_spec.rb @@ -18,7 +18,7 @@ } end let :pre_condition do - 'class { "patterndb": base_dir => "/BASEDIR", } + 'class { "patterndb": } patterndb::simple::ruleset { "myruleset": id => "RULESET_ID", pubdate => "1970-01-01", diff --git a/spec/defines/simple_rule_spec.rb b/spec/defines/simple_rule_spec.rb index f65d0f2..ce2470b 100644 --- a/spec/defines/simple_rule_spec.rb +++ b/spec/defines/simple_rule_spec.rb @@ -18,7 +18,7 @@ } end let :pre_condition do - 'class { "patterndb": base_dir => "/BASEDIR", } + 'class { "patterndb": } patterndb::simple::ruleset { "myruleset": id => "RULESET_ID", pubdate => "1970-01-01", @@ -78,13 +78,13 @@ when 'FreeBSD' it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with( - path: '/BASEDIR/usr/local/etc/patterndb.d/default/myruleset.pdb' + path: '/usr/local/etc/patterndb.d/default/myruleset.pdb' ) } else it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with( - path: '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb' + path: '/etc/syslog-ng/patterndb.d/default/myruleset.pdb' ) } end diff --git a/spec/defines/simple_ruleset_spec.rb b/spec/defines/simple_ruleset_spec.rb index 8be632a..76a63cc 100644 --- a/spec/defines/simple_ruleset_spec.rb +++ b/spec/defines/simple_ruleset_spec.rb @@ -20,7 +20,7 @@ } end let :pre_condition do - 'class { "patterndb": base_dir => "/BASEDIR", } + 'class { "patterndb": } Exec { path => ["/bin","/usr/bin"] }' end @@ -61,9 +61,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/usr/local/etc/patterndb.d/default/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/usr/local/etc/patterndb.d/default/myruleset.pdb') } else - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } end it { is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content( @@ -86,9 +86,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/usr/local/etc/patterndb.d/default/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/usr/local/etc/patterndb.d/default/myruleset.pdb') } else - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } end it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').that_notifies( @@ -148,9 +148,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/usr/local/etc/patterndb.d/PARSER/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/usr/local/etc/patterndb.d/PARSER/myruleset.pdb') } else - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/PARSER/myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/PARSER/myruleset.pdb') } end it { @@ -322,9 +322,9 @@ case facts[:osfamily] when 'FreeBSD' - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/usr/local/etc/patterndb.d/default/123myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/usr/local/etc/patterndb.d/default/123myruleset.pdb') } else - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/123myruleset.pdb') } + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/default/123myruleset.pdb') } end it { is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content(