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