Puppet Class: clamav

Defined in:
modules/clamav/manifests/init.pp

Overview

Parameters:

  • proxy (Any) (defaults to: undef)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'modules/clamav/manifests/init.pp', line 10

class clamav($proxy=undef) {
    package { [ 'clamav-daemon', 'clamav-freshclam' ]:
        ensure => present,
    }

    exec { 'add clamav to Debian-exim':
        command => 'usermod -a -G Debian-exim clamav',
        unless  => 'id -Gn clamav | grep -q Debian-exim',
        path    => '/bin:/sbin:/usr/bin:/usr/sbin',
        require =>  Package['clamav-daemon'],
    }

    file { '/etc/clamav/clamd.conf':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        source  => 'puppet:///modules/clamav/clamd.conf',
        require => Package['clamav-daemon'],
    }

    # Add proxy settings to freshclam
    if $proxy {
        $proxy_arr = split($proxy, ':')
        $proxy_host = $proxy_arr[0]
        $proxy_port = $proxy_arr[1]

        file_line { 'freshclam_proxyserver':
            line   => "HTTPProxyServer ${proxy_host}",
            match  => '^HTTPProxyServer',
            path   => '/etc/clamav/freshclam.conf',
            notify => Service['clamav-freshclam'],
        }
        file_line { 'freshclam_proxyport':
            line   => "HTTPProxyPort ${proxy_port}",
            match  => '^HTTPProxyPort',
            path   => '/etc/clamav/freshclam.conf',
            notify => Service['clamav-freshclam'],
        }
    }

    service { 'clamav-freshclam':
        ensure  => running,
        require => Package['clamav-freshclam'],
    }

    base::service_auto_restart { 'clamav-freshclam': }

    service { 'clamav-daemon':
        ensure    => running,
        require   => File['/etc/clamav/clamd.conf'],
        subscribe => File['/etc/clamav/clamd.conf'],
    }
}