Remove wheezy-supporting cruft
[mirror/dsa-puppet.git] / modules / apache2 / manifests / init.pp
1 # = Class: apache2
2 #
3 # Standard apache config debian.org hosts
4 #
5 # == Sample Usage:
6 #
7 #   include apache2
8 #
9 class apache2 {
10         package { 'apache2':
11                 ensure => installed,
12         }
13
14         service { 'apache2':
15                 ensure  => running,
16                 require => Package['apache2'],
17         }
18
19         apache2::module { 'reqtimeout': }
20         apache2::module { 'info': }
21         apache2::module { 'status': }
22         apache2::module { 'headers': }
23         apache2::module { 'macro': }
24
25         apache2::site { '00-default':
26                 site     => 'default-debian.org',
27                 content  => template('apache2/default-debian.org.erb'),
28         }
29         apache2::site { 'xx-default-ssl':
30                 site     => 'default-debian.org-ssl',
31                 content  => template('apache2/default-debian.org-ssl.erb'),
32         }
33
34         apache2::site { '000-default':
35                 ensure => absent,
36         }
37
38         apache2::config { 'serve-cgi-bin':
39                 ensure => absent,
40         }
41
42         if has_role('udd') {
43                 $memlimit = 512 * 1024 * 1024
44         } elsif has_role('dgit_git') {
45                 $memlimit = 512 * 1024 * 1024
46         } elsif has_role('sso') {
47                 $memlimit = 512 * 1024 * 1024
48         } elsif has_role('popcon') {
49                 $memlimit = 512 * 1024 * 1024
50         } elsif has_role('qamaster') {
51                 $memlimit = 300 * 1024 * 1024
52         } else {
53                 $memlimit = 192 * 1024 * 1024
54         }
55
56         apache2::config { 'resource-limits':
57                 content => template('apache2/resource-limits.erb'),
58         }
59
60         apache2::config { 'security':
61                 source => 'puppet:///modules/apache2/security',
62         }
63
64         apache2::config { 'logformat-privacy':
65                 source => 'puppet:///modules/apache2/logformat-privacy',
66         }
67
68         apache2::config { 'local-serverinfo':
69                 source => 'puppet:///modules/apache2/local-serverinfo',
70         }
71
72         apache2::config { 'server-status':
73                 source => 'puppet:///modules/apache2/server-status',
74         }
75
76         apache2::config { 'puppet-ssl-macros':
77                 source => 'puppet:///modules/apache2/puppet-ssl-macros',
78         }
79
80         apache2::config { 'puppet-ftp-macros':
81                 source => 'puppet:///modules/apache2/puppet-ftp-macros',
82         }
83
84         apache2::config { 'puppet-config':
85                 content => template('apache2/puppet-config.erb'),
86         }
87
88         apache2::config { 'pratchett':
89                 ensure => 'absent',
90         }
91
92         apache2::config { 'headers':
93                 source => 'puppet:///modules/apache2/headers',
94         }
95
96         apache2::config { 'disabled-service':
97                 source => 'puppet:///modules/apache2/disabled-service',
98         }
99
100         apache2::module { 'mpm_event': ensure => absent }
101         if has_role('apache_prefork') {
102                 apache2::module { 'mpm_worker': ensure => absent }
103                 apache2::module { 'mpm_prefork': }
104         } else {
105                 apache2::module { 'mpm_prefork': ensure => absent }
106                 apache2::module { 'mpm_worker': }
107         }
108         file { '/etc/apache2/mods-available/mpm_worker.conf':
109                 content => template('apache2/mpm_worker.erb'),
110         }
111
112         file { '/etc/apache2/sites-available/common-ssl.inc':
113                 ensure => absent,
114         }
115
116         file { '/etc/logrotate.d/apache2':
117                 source => 'puppet:///modules/apache2/apache2.logrotate',
118         }
119
120         file { [ '/srv/www', '/srv/www/default.debian.org', '/srv/www/default.debian.org/htdocs', '/srv/www/default.debian.org/htdocs-disabled' ]:
121                 ensure  => directory,
122                 mode    => '0755',
123         }
124
125         file { '/srv/www/default.debian.org/htdocs/index.html':
126                 content => template('apache2/default-index.html'),
127         }
128
129         file { '/srv/www/default.debian.org/htdocs-disabled/index.html':
130                 content => template('apache2/disabled-index.html'),
131         }
132
133         file { '/var/log/apache2':
134                 ensure => directory,
135                 mode   => '0755',
136         }
137         file { '/var/log/apache2/.nobackup':
138                 mode    => '0644',
139                 content => '',
140         }
141
142         munin::check { 'apache_accesses': }
143         munin::check { 'apache_processes': }
144         munin::check { 'apache_volume': }
145         munin::check { 'apache_servers': }
146         munin::check { 'ps_apache2':
147                 script => 'ps_',
148         }
149         # The munin script needs this
150         package { 'libwww-perl':
151                 ensure => installed,
152         }
153
154         if (! has_role('apache_not_public')) {
155                 if has_role('apache_ratelimited') {
156                         include apache2::dynamic
157                 } else {
158                         @ferm::rule { 'dsa-http':
159                                 prio        => '23',
160                                 description => 'Allow web access',
161                                 rule        => '&SERVICE(tcp, (http https))'
162                         }
163
164                         @ferm::rule { 'dsa-http-v6':
165                                 domain          => '(ip6)',
166                                 prio            => '23',
167                                 description     => 'Allow web access',
168                                 rule            => '&SERVICE(tcp, (http https))'
169                         }
170                 }
171         }
172
173         exec { 'service apache2 reload':
174                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
175                 command     => 'service apache2 reload',
176                 refreshonly => true,
177                 require =>  Package['apache2'],
178         }
179
180         apache2::config { 'puppet-ssl-key-pins':
181                 content => template('apache2/ssl-key-pins.erb'),
182                 notify  => Exec['service apache2 reload'],
183         }
184
185         file { '/etc/cron.d/puppet-export-scheduled-shutdown': ensure => absent, }
186         concat::fragment { 'dsa-puppet-stuff--apache-export-shutdown':
187                 target => '/etc/cron.d/dsa-puppet-stuff',
188                 content  => @(EOF)
189                         */2 * * * * root mkdir -p /run/dsa/shutdown-marker; if dsa-is-shutdown-scheduled; then echo 'system-in-shutdown' > /run/dsa/shutdown-marker/shutdown-in-progress; else rm -f /run/dsa/shutdown-marker/shutdown-in-progress; fi
190                         | EOF
191         }
192         apache2::config { 'local-scheduled-shutdown':
193                 source  => 'puppet:///modules/apache2/local-scheduled-shutdown',
194         }
195 }