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