Puppet Class: exim4

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

Overview

Parameters:

  • config (String)
  • variant (Exim4::Variant) (defaults to: 'light')
  • queuerunner (Exim4::Queuerunner) (defaults to: 'combined')
  • config_dir (Stdlib::Unixpath) (defaults to: '/etc/exim4')
  • filter (Optional[String]) (defaults to: undef)


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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'modules/exim4/manifests/init.pp', line 19

class exim4(
  String             $config,
  Exim4::Variant     $variant     = 'light',
  Exim4::Queuerunner $queuerunner = 'combined',
  Stdlib::Unixpath   $config_dir  = '/etc/exim4',
  Optional[String]   $filter      = undef,
) {
    $aliases_dir = "${config_dir}/aliases"
    $dkim_dir    = "${config_dir}/dkim"
    package { [
        'exim4-config',
        "exim4-daemon-${variant}",
        ]:
        ensure => installed,
    }

    $servicestatus = $queuerunner ? {
        'queueonly' => false,
        default     => true,
    }

    service { 'exim4':
        ensure    => running,
        hasstatus => $servicestatus,
        require   => Package["exim4-daemon-${variant}"],
    }

    # mount tmpfs over the scan & db directories, for efficiency
    if $variant == 'heavy' {
        # allow o+x for /var/spool/exim4 so that subdirs below can be accessed
        file { '/var/spool/exim4':
            ensure  => directory,
            owner   => 'Debian-exim',
            group   => 'Debian-exim',
            mode    => '0751',
            require => Package["exim4-daemon-${variant}"],
        }

        # catch-22 with Puppet + mkdir/mount/chmod. The Debian package doesn't
        # ship $spool/scan, but exim4/exiscan mkdirs it on demand
        exec { 'mkdir /var/spool/exim4/scan':
            path    => '/bin:/usr/bin',
            creates => '/var/spool/exim4/scan',
            require => Package["exim4-daemon-${variant}"],
        }

        mount { [ '/var/spool/exim4/scan', '/var/spool/exim4/db' ]:
            ensure  => mounted,
            device  => 'none',
            fstype  => 'tmpfs',
            options => 'defaults',
            atboot  => true,
            require => Exec['mkdir /var/spool/exim4/scan'],
            before  => Service['exim4'],
        }

        file { [ '/var/spool/exim4/scan', '/var/spool/exim4/db' ]:
            ensure  => directory,
            owner   => 'Debian-exim',
            group   => 'Debian-exim',
            mode    => '1777',
            require => Mount['/var/spool/exim4/scan', '/var/spool/exim4/db'],
            before  => Service['exim4'],
        }
    }

    # shortcuts update-exim4.conf from messing with us
    # and stops debconf prompts about it from showing up
    file { "${config_dir}/update-exim4.conf.conf":
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => "dc_eximconfig_configtype=none\n",
        require => Package['exim4-config'],
    }

    file { '/etc/default/exim4':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('exim4/exim4.default.erb'),
        require => Package['exim4-config'],
    }

    file { $aliases_dir:
        ensure  => directory,
        owner   => 'root',
        group   => 'Debian-exim',
        mode    => '0755',
        require => Package['exim4-config'],
    }

    file { $dkim_dir:
        ensure  => directory,
        purge   => true,
        owner   => 'root',
        group   => 'Debian-exim',
        mode    => '0750',
        require => Package['exim4-config'],
    }

    $filter_ensure = $filter ? {
        undef   => absent,
        default => present,
    }

    file { "${config_dir}/system_filter":
        ensure  => $filter_ensure,
        owner   => 'root',
        group   => 'Debian-exim',
        mode    => '0444',
        content => $filter,
        require => Package['exim4-config'],
    }

    file { "${config_dir}/exim4.conf":
        ensure  => present,
        owner   => 'root',
        group   => 'Debian-exim',
        mode    => '0440',
        content => $config,
        require => Package['exim4-config'],
        notify  => Service['exim4'],
    }
}