Skip to content

Commit

Permalink
Rely on Hiera to get var directory
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Sep 3, 2024
1 parent 44ed842 commit db09c97
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
1 change: 1 addition & 0 deletions data/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions data/osfamily/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
patterndb::config_dir: /usr/local/etc/patterndb.d
patterndb::var_dir: /var/syslog-ng
18 changes: 8 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions manifests/parser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/raw_ruleset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +32,7 @@
end

it {
is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb')
is_expected.to contain_file('/etc/syslog-ng/patterndb.d/default/myrawruleset.pdb')
}
end

Expand All @@ -45,7 +45,7 @@
end

it {
is_expected.to contain_file('BASEDIR/etc/syslog-ng/patterndb.d/default/myrawruleset').with(
is_expected.to contain_file('/etc/syslog-ng/patterndb.d/default/myrawruleset').with(
ensure: 'directory'
)
}
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/simple_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions spec/defines/simple_ruleset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
end
let :pre_condition do
'class { "patterndb": base_dir => "/BASEDIR", }
'class { "patterndb": }
Exec { path => ["/bin","/usr/bin"] }'
end

Expand Down Expand Up @@ -60,7 +60,7 @@
it { is_expected.to contain_patterndb__parser('default') }

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').with('path' => '/etc/syslog-ng/patterndb.d/default/myruleset.pdb')
is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content(
%r{<patterns>.*<pattern>P1</pattern>.*</patterns>}m
)
Expand All @@ -80,7 +80,7 @@
it { is_expected.to contain_patterndb__parser('default') }

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').with('path' => '/etc/syslog-ng/patterndb.d/default/myruleset.pdb')
is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').that_notifies(
'Exec[patterndb::merge::default]'
)
Expand Down Expand Up @@ -135,7 +135,7 @@

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') }
it { is_expected.to contain_concat('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/PARSER/myruleset.pdb') }

it {
is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with(
Expand Down Expand Up @@ -305,7 +305,7 @@
it { is_expected.to contain_patterndb__parser('default') }

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('patterndb_simple_ruleset-myruleset').with('path' => '/etc/syslog-ng/patterndb.d/default/123myruleset.pdb')
is_expected.to contain_concat__fragment('patterndb_simple_ruleset-myruleset-header').with_content(
%r{<patterns>.*<pattern>P1</pattern>.*</patterns>}m
)
Expand Down

0 comments on commit db09c97

Please sign in to comment.