Puppet Class: profile::mail::mx

Defined in:
modules/profile/manifests/mail/mx.pp

Overview

Parameters:

  • prometheus_nodes (Array[Stdlib::Host]) (defaults to: lookup('prometheus_nodes'))

    The set of Prometheus servers which will query for metrics

  • dkim_domain (Stdlib::Host) (defaults to: lookup('profile::mail::mx::dkim_domain'))

    Configure dkim for this domain

  • verp_domains (Array[Stdlib::Host]) (defaults to: lookup('profile::mail::mx::verp_domains'))

    configure verp for theses domains

  • verp_post_connect_server (Stdlib::Host) (defaults to: lookup('profile::mail::mx::verp_post_connect_server'))

    the server to post verp bounces too

  • verp_bounce_post_url (String[1]) (defaults to: lookup('profile::mail::mx::verp_bounce_post_url'))

    the url top post verp bounces to



7
8
9
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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'modules/profile/manifests/mail/mx.pp', line 7

class profile::mail::mx (
    Array[Stdlib::Host]   $prometheus_nodes         = lookup('prometheus_nodes'),
    Stdlib::Host          $dkim_domain              = lookup('profile::mail::mx::dkim_domain'),
    Array[Stdlib::Host]   $verp_domains             = lookup('profile::mail::mx::verp_domains'),
    Stdlib::Host          $verp_post_connect_server = lookup('profile::mail::mx::verp_post_connect_server'),
    String[1]             $verp_bounce_post_url     = lookup('profile::mail::mx::verp_bounce_post_url'),
) {
    mailalias { 'root':
        recipient => 'root@wikimedia.org',
    }

    acme_chief::cert { 'mx':
        puppet_svc => undef,
        key_group  => 'Debian-exim',
    }

    $trusted_networks = $network::constants::aggregate_networks.filter |$x| {
        $x !~ /127.0.0.0|::1/
    }

    class { 'spamassassin':
        required_score   => '4.0',
        use_bayes        => '1',
        bayes_auto_learn => '1',
        max_children     => 32,
        trusted_networks => $trusted_networks,
    }

    include passwords::exim
    $otrs_mysql_password = $passwords::exim::otrs_mysql_password
    $smtp_ldap_password  = $passwords::exim::smtp_ldap_password

    class { 'exim4':
        variant => 'heavy',
        config  => template('role/exim/exim4.conf.mx.erb'),
        filter  => template('role/exim/system_filter.conf.erb'),
        require => Class['spamassassin'],
    }

    file { "${exim4::config_dir}/defer_domains":
        ensure  => present,
        owner   => 'root',
        group   => 'Debian-exim',
        mode    => '0444',
        require => Class['exim4'],
    }

    file { "${exim4::config_dir}/wikimedia_domains":
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        source  => 'puppet:///modules/role/exim/wikimedia_domains',
        require => Class['exim4'],
    }

    file { "${exim4::config_dir}/legacy_mailing_lists":
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        source  => 'puppet:///modules/role/exim/legacy_mailing_lists',
        require => Class['exim4'],
    }

    file { "${exim4::config_dir}/bounce_message_file":
        ensure => present,
        owner  => 'root',
        group  => 'Debian-exim',
        mode   => '0444',
        source => 'puppet:///modules/role/exim/bounce_message_file',
    }
    file { "${exim4::config_dir}/warn_message_file":
        ensure => present,
        owner  => 'root',
        group  => 'Debian-exim',
        mode   => '0444',
        source => 'puppet:///modules/role/exim/warn_message_file',
    }

    exim4::dkim { 'wikimedia.org':
        domain   => $dkim_domain,
        selector => 'wikimedia',
        content  => secret("dkim/${dkim_domain}-wikimedia.key"),
    }
    exim4::dkim { 'wiki-mail':
        domain   => $dkim_domain,
        selector => 'wiki-mail',
        content  => secret("dkim/${dkim_domain}-wiki-mail.key"),
    }

    monitoring::service { 'smtp':
        description   => 'Exim SMTP',
        check_command => 'check_smtp_tls_le',
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Mail#Troubleshooting',
    }

    ferm::service { 'exim-smtp':
        proto => 'tcp',
        port  => '25',
    }

    # mails the wikimedia.org mail alias file to OIT once per week
    $alias_file = "${exim4::aliases_dir}/wikimedia.org"
    $recipient  = 'its@wikimedia.org'
    $subject    = "wikimedia.org mail aliases from ${::hostname}"
    cron { 'mail_exim_aliases':
        user    => 'Debian-exim',
        minute  => 0,
        hour    => 0,
        weekday => 0,
        command => "/usr/bin/mail -s '${subject}' ${recipient} < ${alias_file} >/dev/null 2>&1",
    }

    # Customize logrotate settings to support longer retention (T167333)
    logrotate::conf { 'exim4-base':
        ensure => 'present',
        source => 'puppet:///modules/role/exim/logrotate/exim4-base.mx',
    }

    # monitor mail queue size (T133110)
    file { '/usr/local/lib/nagios/plugins/check_exim_queue':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => 'puppet:///modules/icinga/check_exim_queue.sh',
    }

    sudo::user { 'nagios_exim_queue':
        user       => 'nagios',
        privileges => ['ALL = NOPASSWD: /usr/sbin/exipick -bpc -o [[\:digit\:]][[\:digit\:]][mh]'],
    }

    nrpe::monitor_service { 'check_exim_queue':
        description    => 'exim queue',
        nrpe_command   => '/usr/local/lib/nagios/plugins/check_exim_queue -w 2000 -c 4000',
        check_interval => 30,
        retry_interval => 10,
        timeout        => 20,
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Exim',
    }

    mtail::program { 'exim':
        ensure => present,
        notify => Service['mtail'],
        source => 'puppet:///modules/mtail/programs/exim.mtail',
    }

    $prometheus_nodes_ferm = join($prometheus_nodes, ' ')

    ferm::service { 'mtail':
        proto  => 'tcp',
        port   => '3903',
        srange => "(@resolve((${prometheus_nodes_ferm})) @resolve((${prometheus_nodes_ferm}), AAAA))",
    }
}