Puppet Class: openscap::schedule
- Defined in:
- manifests/schedule.pp
Overview
This class allows you to set a schedule for openscap to run a check on your system via cron.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'manifests/schedule.pp', line 52
class openscap::schedule (
Openscap::Profile $scap_profile,
Pattern[/^.+\.xml$/] $ssg_data_stream,
Stdlib::Absolutepath $oscap_path = pick(fact('oscap.path'), '/bin/oscap'),
Stdlib::Absolutepath $ssg_base_dir = '/usr/share/xml/scap/ssg/content',
Boolean $fetch_remote_resources = false,
Optional[Stdlib::Absolutepath] $scap_tailoring_file = undef,
Stdlib::Absolutepath $logdir = '/var/log/openscap',
Boolean $logrotate = simplib::lookup('simp_options::logrotate', { 'default_value' => false}),
Simplib::Cron::Minute $minute = 30,
Simplib::Cron::Hour $hour = 1,
Simplib::Cron::MonthDay $monthday = '*',
Simplib::Cron::Month $month = '*',
Simplib::Cron::Weekday $weekday = 1,
Boolean $force = false
) {
include 'openscap'
if $force {
$_set_schedule = true
}
else {
if $facts['oscap'] {
$_ssg_ds_basename = basename($ssg_data_stream, '.xml')
if !$facts['oscap']['profiles'] {
fail('No SCAP Profiles found')
}
elsif !$facts['oscap']['profiles'][$ssg_base_dir] {
fail("No SCAP Data Streams found under '${ssg_base_dir}'")
}
elsif !$facts['oscap']['profiles'][$ssg_base_dir][$_ssg_ds_basename] {
fail("Could not find SCAP Data Stream '${ssg_data_stream}'")
}
elsif !$facts['oscap']['profiles'][$ssg_base_dir][$_ssg_ds_basename][$scap_profile] {
fail("Could not find SCAP Profile '${scap_profile}'")
}
else {
$_set_schedule = true
}
}
else {
notify { 'Could not find oscap binary on the system, not setting schedule':
loglevel => 'warning'
}
$_set_schedule = false
}
}
if $_set_schedule {
file { $logdir:
ensure => directory,
mode => '0600',
}
$host = $facts['networking']['fqdn']
cron { 'openscap':
command => template('openscap/oscap_command.erb'),
user => 'root',
minute => $minute,
hour => $hour,
monthday => $monthday,
month => $month,
weekday => $weekday
}
if $logrotate {
include 'logrotate'
logrotate::rule { 'openscap':
log_files => [ "${logdir}/*.xml" ],
missingok => true,
rotate_period => 'daily',
rotate => 3,
lastaction_restart_logger => true
}
}
}
}
|