Skip to content

Commit

Permalink
Replate temp_dir with cache_dir
Browse files Browse the repository at this point in the history
According to hier(7), /var/cache/ is used to store miscellaneous cached
files, precisely what merged patterns not yet installed are.
  • Loading branch information
smortex committed Sep 3, 2024
1 parent 960f7d3 commit c8e98b6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ This module will manage the pattern databases of *syslog-ng* by using existing f

### What patterndb affects

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

0. (OPTIONAL) Manage package `syslog-ng`
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*.
3. Merge the contents of the latter using `pdbtool` into a temporary file `${cache_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*.
4. (OPTIONAL) Test the resulting patterndbs
5. Deploy the temporary files into `${base_dir}/var/lib/syslog-ng/patterndb/${parser}.xml`

Expand Down
1 change: 0 additions & 1 deletion data/default.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
patterndb::base_dir: /
patterndb::temp_dir: /tmp/syslog-ng
patterndb::package_name: false
patterndb::manage_package: true
patterndb::package_name: syslog-ng
Expand Down
4 changes: 2 additions & 2 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 $cache_dir = '/var/cache/syslog-ng',
String[1] $base_dir = '/',
String[1] $temp_dir = "${base_dir}/tmp/syslog-ng",
Boolean $manage_package = true,
Array[String[1]] $syslogng_modules = [],
Boolean $use_hiera = false,
Expand All @@ -13,7 +13,7 @@
if $manage_package {
ensure_resource ( 'package', $package_name, { 'ensure' => 'installed' })
}
ensure_resource ( 'file', $temp_dir, { ensure => directory })
ensure_resource ( 'file', $cache_dir, { ensure => directory })
ensure_resource (
'file', "${base_dir}/var/lib/syslog-ng",
{ ensure => 'directory' }
Expand Down
10 changes: 5 additions & 5 deletions manifests/parser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@
'force' => true,
'recurse' => true,
})
ensure_resource ('file', "${patterndb::temp_dir}/patterndb", {
ensure_resource ('file', "${patterndb::cache_dir}/patterndb", {
'ensure' => 'directory',
})
ensure_resource ('file', "patterndb::file::${name}", {
'ensure' => 'present',
'path' => "${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml"
})
exec { "patterndb::merge::${name}":
command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::config_dir}/${name} -p ${patterndb::temp_dir}/patterndb/${name}.xml",
command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::config_dir}/${name} -p ${patterndb::cache_dir}/patterndb/${name}.xml",
path => $facts['path'],
logoutput => true,
refreshonly => true,
}

exec { "patterndb::test::${name}":
#command => "/usr/bin/pdbtool --validate test ${::patterndb::temp_dir}/patterndb/${name}.xml $modules",
command => "pdbtool test ${patterndb::temp_dir}/patterndb/${name}.xml ${modules}",
#command => "/usr/bin/pdbtool --validate test ${::patterndb::cache_dir}/patterndb/${name}.xml $modules",
command => "pdbtool test ${patterndb::cache_dir}/patterndb/${name}.xml ${modules}",
path => $facts['path'],
logoutput => true,
refreshonly => true,
}

exec { "patterndb::deploy::${name}":
command => "cp ${patterndb::temp_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/",
command => "cp ${patterndb::cache_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/",
logoutput => true,
path => $facts['path'],
refreshonly => true,
Expand Down

0 comments on commit c8e98b6

Please sign in to comment.