Defined Type: clamav::scan

Defined in:
manifests/scan.pp

Overview

minute

Minute (in cron format) to run the scan. Defaults to a consistently random minute based on the fqdn of the host. Has no impact if enable=false.

month

Month (in cron format) to run the scan. Runs every month by default.

monthday

Month day (in cron format) to run the scan. Runs every month day by default.

move

Move infected files into DIRECTORY. Directory must be writable for the ‘clam’ user or unprivileged user running clamscan.

quiet

Be quiet (only print error messages).

recursive
scan
scanlog
weekday

Parameters:

  • action_error (Any) (defaults to: '')
  • action_ok (Any) (defaults to: '')
  • action_virus (Any) (defaults to: '')
  • enable (Any) (defaults to: true)
  • hour (Any) (defaults to: fqdn_rand(23,$title))
  • minute (Any) (defaults to: fqdn_rand(59,$title))
  • month (Any) (defaults to: 'UNSET')
  • monthday (Any) (defaults to: 'UNSET')
  • copy (Any) (defaults to: false)
  • exclude (Any) (defaults to: [ ])
  • exclude_dir (Any) (defaults to: [ ])
  • flags (Any) (defaults to: '')
  • include (Any) (defaults to: [ ])
  • include_dir (Any) (defaults to: [ ])
  • move (Any) (defaults to: '')
  • quiet (Any) (defaults to: true)
  • recursive (Any) (defaults to: false)
  • scan (Any) (defaults to: [ ])
  • scanlog (Any) (defaults to: "/var/log/clamav/scan_${title}")
  • weekday (Any) (defaults to: 'UNSET')
  • clamscan_bin (Any) (defaults to: 'UNSET')


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
132
133
134
135
136
# File 'manifests/scan.pp', line 65

define clamav::scan (
  $action_error = '',
  $action_ok = '',
  $action_virus = '',
  $enable = true,
  $hour = fqdn_rand(23,$title),
  $minute = fqdn_rand(59,$title),
  $month = 'UNSET',
  $monthday = 'UNSET',
  $copy = false,
  $exclude = [ ],
  $exclude_dir = [ ],
  $flags = '',
  $include = [ ],
  $include_dir = [ ],
  $move = '',
  $quiet = true,
  $recursive = false,
  $scan = [ ],
  $scanlog = "/var/log/clamav/scan_${title}",
  $weekday = 'UNSET',
  $clamscan_bin = 'UNSET',
) {
  if $move != '' { validate_absolute_path($move) }

  include clamav
  $scancmd = "/etc/clamav/scans/${title}"

  case $clamscan_bin {
    'UNSET': { $clamscan = $::clamav::params::clamscan_bin }
    default: {
      validate_absolute_path($clamscan_bin)
      $clamscan = $clamscan_bin
    }
  }

  file { $scancmd:
    ensure  => present,
    owner   => $clamav::params::user,
    mode    => '0500',
    content => template('clamav/scan.sh.erb'),
    require => Class['Clamav'],
  }

  # setup our scheduled job to run this scan
  $cron_ensure = $enable ? {
    true    => 'present',
    default => 'absent',
  }
  $month_r = $month ? {
    'UNSET' => undef,
    default => $month,
  }
  $monthday_r = $monthday ? {
    'UNSET' => undef,
    default => $monthday,
  }
  $weekday_r = $weekday ? {
    'UNSET' => undef,
    default => $weekday,
  }
  cron { "clamav-scan-${title}":
    ensure   => $cron_ensure,
    command  => $scancmd,
    hour     => $hour,
    minute   => $minute,
    month    => $month_r,
    monthday => $monthday_r,
    weekday  => $weekday_r,
    require  => File[$scancmd],
  }
}