Retire debian_org::mail_incoming_port which did the default firewalling for the mail...
[mirror/dsa-puppet.git] / modules / exim / manifests / init.pp
1 # our exim class
2 # @param use_smarthost use the smarthost
3 # @param smarthost host to relay through (if set and use_smarthost)
4 # @param is_bugsmx this system handles bugs.debian.org
5 # @param is_mailrelay this system is a mailrelay, both in and out, for debian hosts
6 # @param is_rtmaster this system handles rt.debian.org
7 # @param is_packagesmaster this system handles packagesrt.debian.org
8 # @param is_packagesqamaster this system handles packages.qa.debian.org
9 # @param mail_port override the default incoming mailport (only applicable for hosts behind an incoming relay)
10 # @param smarthost_port the port on which satellites send mail to the smarthost (needs to be the same on both sides)
11 class exim (
12   Optional[String] $smarthost,
13   Boolean $use_smarthost = true,
14   Boolean $is_bugsmx = false,
15   Boolean $is_mailrelay = false,
16   Boolean $is_rtmaster = false,
17   Boolean $is_packagesmaster = false,
18   Boolean $is_packagesqamaster = false,
19   Integer $smarthost_port = 587,
20   Optional[Integer] $mail_port = undef,
21 ) {
22   include exim::vdomain::setup
23
24   if $use_smarthost {
25     $heavy = false
26
27     if ! smarthost {
28       fail('No smarthost set but use_smarthost is true')
29     }
30   } else {
31     $heavy = true
32     if $mail_port {
33       fail('Cannot override mail_port in heavy/no-smarthost hosts')
34     }
35   }
36
37   munin::check { 'ps_exim4': script => 'ps_' }
38   munin::check { 'exim_mailqueue': }
39   munin::check { 'exim_mailstats': }
40
41   munin::check { 'postfix_mailqueue':  ensure => absent }
42   munin::check { 'postfix_mailstats':  ensure => absent }
43   munin::check { 'postfix_mailvolume': ensure => absent }
44
45   package { 'exim4-daemon-heavy': ensure => installed }
46
47   Package['exim4-daemon-heavy']->Mailalias<| |>
48
49   concat::fragment { 'virtual_domain_template':
50     target  => '/etc/exim4/virtualdomains',
51     content => template('exim/virtualdomains.erb'),
52     order   => '05',
53   }
54
55   service { 'exim4':
56     ensure  => running,
57     require => [
58       File['/etc/exim4/exim4.conf'],
59       Package['exim4-daemon-heavy'],
60     ]
61   }
62
63   file { '/etc/exim4/':
64     ensure  => directory,
65     mode    => '0755',
66     require => Package['exim4-daemon-heavy'],
67     purge   => true,
68   }
69   file { '/etc/exim4/conf.d':
70     ensure  => directory,
71     purge   => true,
72     force   => true,
73     recurse => true,
74     source  => 'puppet:///files/empty/',
75   }
76   file { '/etc/exim4/ssl':
77     ensure => directory,
78     group  => 'Debian-exim',
79     mode   => '0750',
80     purge  => true,
81   }
82   file { '/etc/exim4/exim4.conf':
83     content => template('exim/eximconf.erb'),
84     require => File['/etc/exim4/ssl/thishost.crt'],
85     notify  => Service['exim4'],
86   }
87   file { '/etc/mailname':
88     content => template('exim/mailname.erb'),
89   }
90   file { '/etc/exim4/manualroute':
91     content => template('exim/manualroute.erb')
92   }
93   file { '/etc/exim4/locals':
94     content => template('exim/locals.erb')
95   }
96   file { '/etc/exim4/submission-domains':
97     content => template('exim/submission-domains.erb'),
98   }
99   file { '/etc/exim4/host_blacklist':
100     source => 'puppet:///modules/exim/common/host_blacklist',
101   }
102   file { '/etc/exim4/blacklist':
103     source => 'puppet:///modules/exim/common/blacklist',
104   }
105   file { '/etc/exim4/callout_users':
106     source => 'puppet:///modules/exim/common/callout_users',
107   }
108   file { '/etc/exim4/grey_users':
109     source => 'puppet:///modules/exim/common/grey_users',
110   }
111   file { '/etc/exim4/helo-check':
112     source => 'puppet:///modules/exim/common/helo-check',
113   }
114   file { '/etc/exim4/localusers':
115     source => 'puppet:///modules/exim/common/localusers',
116   }
117   file { '/etc/exim4/rbllist':
118     source => 'puppet:///modules/exim/common/rbllist',
119   }
120   file { '/etc/exim4/rhsbllist':
121     source => 'puppet:///modules/exim/common/rhsbllist',
122   }
123   file { '/etc/exim4/whitelist':
124     source => 'puppet:///modules/exim/common/whitelist',
125   }
126   file { '/etc/logrotate.d/exim4-base':
127     source => 'puppet:///modules/exim/common/logrotate-exim4-base',
128   }
129   file { '/etc/logrotate.d/exim4-paniclog':
130     source => 'puppet:///modules/exim/common/logrotate-exim4-paniclog'
131   }
132   file { '/etc/exim4/ssl/thishost.crt':
133     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".crt") %>'),
134     group   => 'Debian-exim',
135     mode    => '0640',
136   }
137   file { '/etc/exim4/ssl/thishost.key':
138     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".key") %>'),
139     group   => 'Debian-exim',
140     mode    => '0640',
141   }
142   file { '/etc/exim4/ssl/ca.crt':
143     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crt") %>'),
144     group   => 'Debian-exim',
145     mode    => '0640',
146   }
147   file { '/etc/exim4/ssl/ca.crl':
148     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crl") %>'),
149     group   => 'Debian-exim',
150     mode    => '0640',
151   }
152   file { '/var/log/exim4':
153     ensure => directory,
154     mode   => '2750',
155     owner  => 'Debian-exim',
156     group  => maillog,
157   }
158
159   # Do we actually want this?  I'm only doing it because it's harmless
160   # and makes the logs quiet.  There are better ways of making logs quiet,
161   # though.
162   ferm::rule { 'dsa-ident':
163     domain      => '(ip ip6)',
164     description => 'Allow ident access',
165     rule        => '&SERVICE(tcp, 113)'
166   }
167
168   # These only affect the alias @$fqdn, not say, @debian.org
169
170   mailalias { [
171     'postmaster',
172     'hostmaster',
173     'usenet',
174     'webmaster',
175     'abuse',
176     'noc',
177     'security',
178   ]:
179     ensure => absent
180   }
181 }