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