Update the setup for archive.debian.net
[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         apache2::config { 'ressource-limits':
43                 ensure => absent,
44         }
45
46         if has_role('udd') {
47                 $memlimit = 512 * 1024 * 1024
48         } elsif has_role('dgit_git') {
49                 $memlimit = 512 * 1024 * 1024
50         } elsif has_role('sso') {
51                 $memlimit = 512 * 1024 * 1024
52         } elsif has_role('popcon') {
53                 $memlimit = 512 * 1024 * 1024
54         } elsif has_role('qamaster') {
55                 $memlimit = 300 * 1024 * 1024
56         } else {
57                 $memlimit = 192 * 1024 * 1024
58         }
59
60         apache2::config { 'resource-limits':
61                 content => template('apache2/resource-limits.erb'),
62         }
63
64         apache2::config { 'security':
65                 source => 'puppet:///modules/apache2/security',
66         }
67
68         apache2::config { 'logformat-privacy':
69                 source => 'puppet:///modules/apache2/logformat-privacy',
70         }
71
72         apache2::config { 'local-serverinfo':
73                 source => 'puppet:///modules/apache2/local-serverinfo',
74         }
75
76         apache2::config { 'server-status':
77                 source => 'puppet:///modules/apache2/server-status',
78         }
79
80         apache2::config { 'puppet-ssl-macros':
81                 source => 'puppet:///modules/apache2/puppet-ssl-macros',
82         }
83
84         apache2::config { 'puppet-ftp-macros':
85                 source => 'puppet:///modules/apache2/puppet-ftp-macros',
86         }
87
88         apache2::config { 'puppet-config':
89                 content => template('apache2/puppet-config.erb'),
90         }
91
92         apache2::config { 'pratchett':
93                 ensure => 'absent',
94         }
95
96         apache2::config { 'headers':
97                 source => 'puppet:///modules/apache2/headers',
98         }
99
100         apache2::config { 'disabled-service':
101                 source => 'puppet:///modules/apache2/disabled-service',
102         }
103
104         apache2::module { 'mpm_event': ensure => absent }
105         if has_role('apache_prefork') {
106                 apache2::module { 'mpm_worker': ensure => absent }
107                 apache2::module { 'mpm_prefork': }
108         } else {
109                 apache2::module { 'mpm_prefork': ensure => absent }
110                 apache2::module { 'mpm_worker': }
111         }
112         if versioncmp($::lsbmajdistrelease, '7') > 0 {
113                 file { '/etc/apache2/mods-available/mpm_worker.conf':
114                         content => template('apache2/mpm_worker.erb'),
115                 }
116         }
117
118         file { '/etc/apache2/sites-available/common-ssl.inc':
119                 ensure => absent,
120         }
121
122         file { '/etc/logrotate.d/apache2':
123                 source => 'puppet:///modules/apache2/apache2.logrotate',
124         }
125
126         file { [ '/srv/www', '/srv/www/default.debian.org', '/srv/www/default.debian.org/htdocs', '/srv/www/default.debian.org/htdocs-disabled' ]:
127                 ensure  => directory,
128                 mode    => '0755',
129         }
130
131         file { '/srv/www/default.debian.org/htdocs/index.html':
132                 content => template('apache2/default-index.html'),
133         }
134
135         file { '/srv/www/default.debian.org/htdocs-disabled/index.html':
136                 content => template('apache2/disabled-index.html'),
137         }
138
139         file { '/var/log/apache2':
140                 ensure => directory,
141                 mode   => '0755',
142         }
143         file { '/var/log/apache2/.nobackup':
144                 mode    => '0644',
145                 content => '',
146         }
147
148         munin::check { 'apache_accesses': }
149         munin::check { 'apache_processes': }
150         munin::check { 'apache_volume': }
151         munin::check { 'apache_servers': }
152         munin::check { 'ps_apache2':
153                 script => 'ps_',
154         }
155         # The munin script needs this
156         package { 'libwww-perl':
157                 ensure => installed,
158         }
159
160         if $::hostname in [beach,buxtehude,picconi,pkgmirror-csail] {
161                 include apache2::dynamic
162         } else {
163                 @ferm::rule { 'dsa-http':
164                         prio        => '23',
165                         description => 'Allow web access',
166                         rule        => '&SERVICE(tcp, (http https))'
167                 }
168         }
169
170         @ferm::rule { 'dsa-http-v6':
171                 domain          => '(ip6)',
172                 prio            => '23',
173                 description     => 'Allow web access',
174                 rule            => '&SERVICE(tcp, (http https))'
175         }
176
177         exec { 'service apache2 reload':
178                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
179                 command     => 'service apache2 reload',
180                 refreshonly => true,
181                 require =>  Package['apache2'],
182         }
183
184         apache2::config { 'puppet-ssl-key-pins':
185                 content => template('apache2/ssl-key-pins.erb'),
186                 notify  => Exec['service apache2 reload'],
187         }
188 }