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