move the remaining virtualdomains to the mailrelay class
[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   service { 'exim4':
50     ensure  => running,
51     require => [
52       File['/etc/exim4/exim4.conf'],
53       Package['exim4-daemon-heavy'],
54     ]
55   }
56
57   file { '/etc/exim4/':
58     ensure  => directory,
59     mode    => '0755',
60     require => Package['exim4-daemon-heavy'],
61     purge   => true,
62   }
63   file { '/etc/exim4/conf.d':
64     ensure  => directory,
65     purge   => true,
66     force   => true,
67     recurse => true,
68     source  => 'puppet:///files/empty/',
69   }
70   file { '/etc/exim4/ssl':
71     ensure => directory,
72     group  => 'Debian-exim',
73     mode   => '0750',
74     purge  => true,
75   }
76   file { '/etc/exim4/exim4.conf':
77     content => template('exim/eximconf.erb'),
78     require => File['/etc/exim4/ssl/thishost.crt'],
79     notify  => Service['exim4'],
80   }
81   file { '/etc/mailname':
82     content => template('exim/mailname.erb'),
83   }
84   file { '/etc/exim4/locals':
85     content => template('exim/locals.erb')
86   }
87   file { '/etc/exim4/submission-domains':
88     content => template('exim/submission-domains.erb'),
89   }
90   file { '/etc/exim4/host_blacklist':
91     source => 'puppet:///modules/exim/common/host_blacklist',
92   }
93   file { '/etc/exim4/blacklist':
94     source => 'puppet:///modules/exim/common/blacklist',
95   }
96   file { '/etc/exim4/callout_users':
97     source => 'puppet:///modules/exim/common/callout_users',
98   }
99   file { '/etc/exim4/grey_users':
100     source => 'puppet:///modules/exim/common/grey_users',
101   }
102   file { '/etc/exim4/helo-check':
103     source => 'puppet:///modules/exim/common/helo-check',
104   }
105   file { '/etc/exim4/localusers':
106     source => 'puppet:///modules/exim/common/localusers',
107   }
108   file { '/etc/exim4/rbllist':
109     source => 'puppet:///modules/exim/common/rbllist',
110   }
111   file { '/etc/exim4/rhsbllist':
112     source => 'puppet:///modules/exim/common/rhsbllist',
113   }
114   file { '/etc/exim4/whitelist':
115     source => 'puppet:///modules/exim/common/whitelist',
116   }
117   file { '/etc/logrotate.d/exim4-base':
118     source => 'puppet:///modules/exim/common/logrotate-exim4-base',
119   }
120   file { '/etc/logrotate.d/exim4-paniclog':
121     source => 'puppet:///modules/exim/common/logrotate-exim4-paniclog'
122   }
123   file { '/etc/exim4/ssl/thishost.crt':
124     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".crt") %>'),
125     group   => 'Debian-exim',
126     mode    => '0640',
127   }
128   file { '/etc/exim4/ssl/thishost.key':
129     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/" + @fqdn + ".key") %>'),
130     group   => 'Debian-exim',
131     mode    => '0640',
132   }
133   file { '/etc/exim4/ssl/ca.crt':
134     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crt") %>'),
135     group   => 'Debian-exim',
136     mode    => '0640',
137   }
138   file { '/etc/exim4/ssl/ca.crl':
139     content => inline_template('<%= File.read(scope().call_function("hiera", ["paths.auto_certs_dir"]) + "/ca.crl") %>'),
140     group   => 'Debian-exim',
141     mode    => '0640',
142   }
143   file { '/var/log/exim4':
144     ensure => directory,
145     mode   => '2750',
146     owner  => 'Debian-exim',
147     group  => maillog,
148   }
149
150   # Do we actually want this?  I'm only doing it because it's harmless
151   # and makes the logs quiet.  There are better ways of making logs quiet,
152   # though.
153   ferm::rule { 'dsa-ident':
154     domain      => '(ip ip6)',
155     description => 'Allow ident access',
156     rule        => '&SERVICE(tcp, 113)'
157   }
158
159   # These only affect the alias @$fqdn, not say, @debian.org
160
161   mailalias { [
162     'postmaster',
163     'hostmaster',
164     'usenet',
165     'webmaster',
166     'abuse',
167     'noc',
168     'security',
169   ]:
170     ensure => absent
171   }
172 }