Skip to content

Commit

Permalink
https://github.com/ccin2p3/puppet-patterndb/pull/44
Browse files Browse the repository at this point in the history
  • Loading branch information
faxm0dem committed Aug 29, 2023
1 parent 8ac2824 commit 1580cd9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 44 deletions.
11 changes: 3 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,9 @@
'file', "${base_dir}/var/lib/syslog-ng",
{ ensure => 'directory' }
)
ensure_resource (
'file', "${base_dir}/var/lib/syslog-ng/patterndb",
{
ensure => 'directory',
purge => true,
recurse => true
}
)
file { "${base_dir}/var/lib/syslog-ng/patterndb":
ensure => 'directory',
}
$pdb_dir = "${base_dir}/etc/syslog-ng/patterndb.d"
file { $pdb_dir:
ensure => directory,
Expand Down
56 changes: 20 additions & 36 deletions manifests/parser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,38 @@
$tmp = join($_modules,' --module=')
$modules = "--module=${tmp}"
}
ensure_resource('file', "${patterndb::pdb_dir}/${name}", {
'ensure' => 'directory',
'purge' => true,
'force' => true,
'recurse' => true,
})

file { "${patterndb::pdb_dir}/${name}":
ensure => 'directory',
force => true,
recurse => true,
purge => true,
}

ensure_resource ('file', "${patterndb::temp_dir}/patterndb", {
'ensure' => 'directory',
})
ensure_resource ('file', "patterndb::file::${name}", {
'ensure' => 'present',
'path' => "${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml"
})

$_test_before_deploy = $test_before_deploy.lest || { $patterndb::test_before_deploy }

exec { "patterndb::merge::${name}":
command => "pdbtool merge -r --glob \\*.pdb -D ${patterndb::pdb_dir}/${name} -p ${patterndb::temp_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}",
path => $facts['path'],
logoutput => true,
refreshonly => true,
$deploy_command = if $_test_before_deploy {
"pdbtool test ${patterndb::temp_dir}/patterndb/${name}.xml ${modules} && cp ${patterndb::temp_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml"
} else {
"cp ${patterndb::temp_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml"
}

exec { "patterndb::deploy::${name}":
command => "cp ${patterndb::temp_dir}/patterndb/${name}.xml ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/",
logoutput => true,
path => $facts['path'],
refreshonly => true,
}
if $test_before_deploy =~ Undef {
$_test_before_deploy = $patterndb::test_before_deploy
} else {
$_test_before_deploy = $test_before_deploy
}
if $_test_before_deploy {
File["patterndb::file::${name}"]
~> Exec["patterndb::merge::${name}"]
~> Exec["patterndb::test::${name}"]
~> Exec["patterndb::deploy::${name}"]
} else {
File["patterndb::file::${name}"]
~> Exec["patterndb::merge::${name}"]
# we won't 'pdbtool test' the merged file before deploying
~> Exec["patterndb::deploy::${name}"]
command => $deploy_command,
path => $facts['path'],
logoutput => true,
onlyif => "[ ! -f ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml -o ${patterndb::temp_dir}/patterndb/${name}.xml -nt ${patterndb::base_dir}/var/lib/syslog-ng/patterndb/${name}.xml ]",
require => Exec["patterndb::merge::${name}"],
}
}

0 comments on commit 1580cd9

Please sign in to comment.