diff --git a/data/default.yaml b/data/default.yaml index f87cece..605edb4 100644 --- a/data/default.yaml +++ b/data/default.yaml @@ -9,4 +9,4 @@ patterndb::use_hiera: false 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 diff --git a/data/osfamily/FreeBSD.yaml b/data/osfamily/FreeBSD.yaml new file mode 100644 index 0000000..b4b0ef7 --- /dev/null +++ b/data/osfamily/FreeBSD.yaml @@ -0,0 +1,2 @@ +--- +patterndb::config_dir: /usr/local/etc/patterndb.d diff --git a/manifests/init.pp b/manifests/init.pp index d55d222..4f9f1f1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,6 +1,7 @@ # class patterndb ( String[1] $package_name, + Stdlib::Absolutepath $config_dir, String[1] $base_dir = '/', String[1] $temp_dir = "${base_dir}/tmp/syslog-ng", Boolean $manage_package = true, @@ -35,8 +36,7 @@ recurse => true } ) - $pdb_dir = "${base_dir}/etc/syslog-ng/patterndb.d" - file { $pdb_dir: + file { $config_dir: ensure => directory, purge => true, force => true, diff --git a/manifests/parser.pp b/manifests/parser.pp index 811ddf3..ed4954e 100644 --- a/manifests/parser.pp +++ b/manifests/parser.pp @@ -15,7 +15,7 @@ $tmp = join($_modules,' --module=') $modules = "--module=${tmp}" } - ensure_resource('file', "${patterndb::pdb_dir}/${name}", { + ensure_resource('file', "${patterndb::config_dir}/${name}", { 'ensure' => 'directory', 'purge' => true, 'force' => true, @@ -29,7 +29,7 @@ 'path' => "${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml" }) exec { "patterndb::merge::${name}": - command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::pdb_dir}/${name} -p ${patterndb::temp_dir}/patterndb/${name}.xml", + command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::config_dir}/${name} -p ${patterndb::temp_dir}/patterndb/${name}.xml", path => $facts['path'], logoutput => true, refreshonly => true, diff --git a/manifests/raw/ruleset.pp b/manifests/raw/ruleset.pp index 39e8e8b..498c4de 100644 --- a/manifests/raw/ruleset.pp +++ b/manifests/raw/ruleset.pp @@ -20,7 +20,7 @@ } if $ensure == 'directory' { - file { "${patterndb::pdb_dir}/${parser}/${name}": + file { "${patterndb::config_dir}/${parser}/${name}": ensure => $ensure, recurse => $recurse, mode => '0644', @@ -31,7 +31,7 @@ notify => Exec["patterndb::merge::${parser}"], } } else { - file { "${patterndb::pdb_dir}/${parser}/${name}.pdb": + file { "${patterndb::config_dir}/${parser}/${name}.pdb": ensure => $ensure, mode => '0644', source => $source, diff --git a/manifests/simple/ruleset.pp b/manifests/simple/ruleset.pp index 207f6a5..5db2fd5 100644 --- a/manifests/simple/ruleset.pp +++ b/manifests/simple/ruleset.pp @@ -25,7 +25,7 @@ } } - $pdb_file = "${patterndb::pdb_dir}/${parser}/${order}${name}.pdb" + $pdb_file = "${patterndb::config_dir}/${parser}/${order}${name}.pdb" concat { "patterndb_simple_ruleset-${title}": path => $pdb_file, diff --git a/spec/defines/raw_ruleset_spec.rb b/spec/defines/raw_ruleset_spec.rb index 542e21d..f2ea1cb 100644 --- a/spec/defines/raw_ruleset_spec.rb +++ b/spec/defines/raw_ruleset_spec.rb @@ -31,9 +31,12 @@ } end - it { - is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb') - } + case facts[:osfamily] + when 'FreeBSD' + it { is_expected.to contain_file('BASEDIR/usr/local/etc/patterndb.d/default/myrawruleset.pdb') } + else + it { is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb') } + end end context 'Raw rulesets with directory' do @@ -44,11 +47,12 @@ } end - it { - is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset').with( - ensure: 'directory' - ) - } + case facts[:osfamily] + when 'FreeBSD' + it { is_expected.to contain_file('BASEDIR/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') } + end end end end diff --git a/spec/defines/simple_rule_spec.rb b/spec/defines/simple_rule_spec.rb index 1f41e53..f65d0f2 100644 --- a/spec/defines/simple_rule_spec.rb +++ b/spec/defines/simple_rule_spec.rb @@ -74,10 +74,21 @@ ) } + 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' + ) + } + else + it { + is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with( + path: '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb' + ) + } + end it { - is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with( - path: '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb' - ) is_expected.to contain_concat__fragment('patterndb_simple_rule-myrule-header').with( target: 'patterndb_simple_ruleset-myruleset' ).with_content( diff --git a/spec/defines/simple_ruleset_spec.rb b/spec/defines/simple_ruleset_spec.rb index 0c72cdd..8be632a 100644 --- a/spec/defines/simple_ruleset_spec.rb +++ b/spec/defines/simple_ruleset_spec.rb @@ -59,8 +59,13 @@ it { is_expected.to contain_patterndb__parser('default') } + 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') } + else + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } + end it { - is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content( %r{.*P1.*}m ) @@ -79,8 +84,13 @@ it { is_expected.to contain_patterndb__parser('default') } + 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') } + else + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') } + end it { - is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/myruleset.pdb') is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').that_notifies( 'Exec[patterndb::merge::default]' ) @@ -135,7 +145,13 @@ it { is_expected.not_to contain_patterndb__parser('default') } it { is_expected.to contain_patterndb__parser('PARSER') } - it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/PARSER/myruleset.pdb') } + + 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') } + else + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/PARSER/myruleset.pdb') } + end it { is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with( @@ -304,8 +320,13 @@ it { is_expected.to contain_patterndb__parser('default') } + 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') } + else + it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/123myruleset.pdb') } + end it { - is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/BASEDIR/etc/syslog-ng/patterndb.d/default/123myruleset.pdb') is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content( %r{.*P1.*}m )