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