0064c8e78d211eb7fdb9bb0226865e8ee77083fe
[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 packages.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   if $use_smarthost {
23     $heavy = false
24
25     if ! smarthost {
26       fail('No smarthost set but use_smarthost is true')
27     }
28   } else {
29     $heavy = true
30     if $mail_port {
31       fail('Cannot override mail_port in heavy/no-smarthost hosts')
32     }
33   }
34
35   munin::check { 'ps_exim4': script => 'ps_' }
36   munin::check { 'exim_mailqueue': }
37   munin::check { 'exim_mailstats': }
38
39   munin::check { 'postfix_mailqueue':  ensure => absent }
40   munin::check { 'postfix_mailstats':  ensure => absent }
41   munin::check { 'postfix_mailvolume': ensure => absent }
42
43   package { 'exim4-daemon-heavy': ensure => installed }
44
45   Package['exim4-daemon-heavy']->Mailalias<| |>
46
47   service { 'exim4':
48     ensure  => running,
49     require => [
50       File['/etc/exim4/exim4.conf'],
51       Package['exim4-daemon-heavy'],
52     ]
53   }
54
55   file { '/etc/exim4/':
56     ensure  => directory,
57     mode    => '0755',
58     require => Package['exim4-daemon-heavy'],
59     purge   => true,
60   }
61   file { '/etc/exim4/conf.d':
62     ensure  => directory,
63     purge   => true,
64     force   => true,
65     recurse => true,
66     source  => 'puppet:///files/empty/',
67   }
68   file { '/etc/exim4/ssl':
69     ensure => directory,
70     group  => 'Debian-exim',
71     mode   => '0750',
72     purge  => true,
73   }
74   file { '/etc/exim4/exim4.conf':
75     content => template('exim/eximconf.erb'),
76     require => File['/etc/exim4/ssl/thishost.crt'],
77     notify  => Service['exim4'],
78   }
79   file { '/etc/mailname':
80     content => template('exim/mailname.erb'),
81   }
82
83   concat { '/etc/exim4/virtualdomains': }
84   concat::fragment { 'virtualdomains_header':
85     target  => '/etc/exim4/virtualdomains',
86     content => template('exim/virtualdomains.header.erb'),
87     order   => '00',
88   }
89
90   file { '/etc/exim4/locals':
91     content => template('exim/locals.erb')
92   }
93   file { '/etc/exim4/submission-domains':
94     content => template('exim/submission-domains.erb'),
95   }
96   file { '/etc/exim4/host_blacklist':
97     source => 'puppet:///modules/exim/common/host_blacklist',
98   }
99   file { '/etc/exim4/blacklist':
100     source => 'puppet:///modules/exim/common/blacklist',
101   }
102   file { '/etc/exim4/callout_users':
103     source => 'puppet:///modules/exim/common/callout_users',
104   }
105   file { '/etc/exim4/grey_users':
106     source => 'puppet:///modules/exim/common/grey_users',
107   }
108   file { '/etc/exim4/helo-check':
109     source => 'puppet:///modules/exim/common/helo-check',
110   }
111   file { '/etc/exim4/localusers':
112     source => 'puppet:///modules/exim/common/localusers',
113   }
114   file { '/etc/exim4/rbllist':
115     source => 'puppet:///modules/exim/common/rbllist',
116   }
117   file { '/etc/exim4/rhsbllist':
118     source => 'puppet:///modules/exim/common/rhsbllist',
119   }
120   file { '/etc/exim4/whitelist':
121     source => 'puppet:///modules/exim/common/whitelist',
122   }
123   file { '/etc/logrotate.d/exim4-base':
124     source => 'puppet:///modules/exim/common/logrotate-exim4-base',
125   }
126   file { '/etc/logrotate.d/exim4-paniclog':
127     source => 'puppet:///modules/exim/common/logrotate-exim4-paniclog'
128   }
129   file { '/etc/exim4/ssl/thishost.crt':
130     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".crt") %>'),
131     group   => 'Debian-exim',
132     mode    => '0640',
133   }
134   file { '/etc/exim4/ssl/thishost.key':
135     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".key") %>'),
136     group   => 'Debian-exim',
137     mode    => '0640',
138   }
139   file { '/etc/exim4/ssl/ca.crt':
140     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crt") %>'),
141     group   => 'Debian-exim',
142     mode    => '0640',
143   }
144   file { '/etc/exim4/ssl/ca.crl':
145     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crl") %>'),
146     group   => 'Debian-exim',
147     mode    => '0640',
148   }
149   file { '/var/log/exim4':
150     ensure => directory,
151     mode   => '2750',
152     owner  => 'Debian-exim',
153     group  => maillog,
154   }
155
156   # Do we actually want this?  I'm only doing it because it's harmless
157   # and makes the logs quiet.  There are better ways of making logs quiet,
158   # though.
159   ferm::rule { 'dsa-ident':
160     domain      => '(ip ip6)',
161     description => 'Allow ident access',
162     rule        => '&SERVICE(tcp, 113)'
163   }
164
165   # These only affect the alias @$fqdn, not say, @debian.org
166
167   mailalias { [
168     'postmaster',
169     'hostmaster',
170     'usenet',
171     'webmaster',
172     'abuse',
173     'noc',
174     'security',
175   ]:
176     ensure => absent
177   }
178 }