cdbuilder_local_mirror role cleanup
[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 # @param smaller_number_of_threads by default the worker config is geared towards
10 #                                  serving static/cheap content.  If the host is very
11 #                                  script heavy (say the bug tracking system), set this
12 #                                  to reduce the number of worker threads.
13 # @param rlimitnproc A resource limit for number of processes.  The default is usually fine.
14 # @param public Whether this host's apache should be accessible from the public internet.
15 #               Sets appropriate firewall rules and optionally rate limits.
16 class apache2(
17   Boolean $smaller_number_of_threads = false,
18   Integer $rlimitnproc = 256,
19   Boolean $public = true,
20 ) {
21   include webserver
22
23   package { 'apache2':
24     ensure => installed,
25   }
26
27   service { 'apache2':
28     ensure  => running,
29     require => Package['apache2'],
30   }
31
32   apache2::module { 'reqtimeout': }
33   apache2::module { 'info': }
34   apache2::module { 'status': }
35   apache2::module { 'headers': }
36   apache2::module { 'macro': }
37
38   apache2::site { '00-default':
39     site    => 'default-debian.org',
40     content => template('apache2/default-debian.org.erb'),
41   }
42   apache2::site { 'xx-default-ssl':
43     site    => 'default-debian.org-ssl',
44     content => template('apache2/default-debian.org-ssl.erb'),
45   }
46
47   apache2::site { '000-default':
48     ensure => absent,
49   }
50
51   apache2::config { 'serve-cgi-bin':
52     ensure => absent,
53   }
54
55   if has_role('udd') {
56     $memlimit = 512 * 1024 * 1024
57   } elsif has_role('dgit_git') {
58     $memlimit = 512 * 1024 * 1024
59   } elsif has_role('sso') {
60     $memlimit = 512 * 1024 * 1024
61   } elsif has_role('popcon') {
62     $memlimit = 512 * 1024 * 1024
63   } elsif has_role('qamaster') {
64     $memlimit = 300 * 1024 * 1024
65   } else {
66     $memlimit = 192 * 1024 * 1024
67   }
68
69   apache2::config { 'resource-limits':
70     content => template('apache2/resource-limits.erb'),
71   }
72
73   apache2::config { 'security':
74     source => 'puppet:///modules/apache2/security',
75   }
76
77   apache2::config { 'logformat-privacy':
78     source => 'puppet:///modules/apache2/logformat-privacy',
79   }
80
81   apache2::config { 'local-serverinfo':
82     source => 'puppet:///modules/apache2/local-serverinfo',
83   }
84
85   apache2::config { 'server-status':
86     source => 'puppet:///modules/apache2/server-status',
87   }
88
89   apache2::config { 'puppet-ssl-macros':
90     source => 'puppet:///modules/apache2/puppet-ssl-macros',
91   }
92
93   apache2::config { 'puppet-ftp-macros':
94     source => 'puppet:///modules/apache2/puppet-ftp-macros',
95   }
96
97   apache2::config { 'puppet-config':
98     content => template('apache2/puppet-config.erb'),
99   }
100
101   apache2::config { 'headers':
102     source => 'puppet:///modules/apache2/headers',
103   }
104
105   apache2::config { 'disabled-service':
106     source => 'puppet:///modules/apache2/disabled-service',
107   }
108
109   apache2::module { 'mpm_event': ensure => absent }
110   if has_role('apache_prefork') {
111     apache2::module { 'mpm_worker': ensure => absent }
112     apache2::module { 'mpm_prefork': }
113   } else {
114     apache2::module { 'mpm_prefork': ensure => absent }
115     apache2::module { 'mpm_worker': }
116   }
117   file { '/etc/apache2/mods-available/mpm_worker.conf':
118     content => template('apache2/mpm_worker.erb'),
119   }
120
121   file { '/etc/logrotate.d/apache2':
122     source => 'puppet:///modules/apache2/apache2.logrotate',
123   }
124
125   file { '/var/log/apache2':
126     ensure => directory,
127     mode   => '0755',
128   }
129   file { '/var/log/apache2/.nobackup':
130     mode    => '0644',
131     content => '',
132   }
133
134   munin::check { 'apache_accesses': }
135   munin::check { 'apache_processes': }
136   munin::check { 'apache_volume': }
137   munin::check { 'apache_servers': }
138   munin::check { 'ps_apache2':
139     script => 'ps_',
140   }
141   # The munin script needs this
142   package { 'libwww-perl':
143     ensure => installed,
144   }
145
146   if $public {
147     if has_role('apache_ratelimited') {
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       ferm::rule { 'dsa-http-v6':
157         domain      => '(ip6)',
158         prio        => '23',
159         description => 'Allow web access',
160         rule        => '&SERVICE(tcp, (http https))'
161       }
162     }
163   }
164
165   exec { 'service apache2 reload':
166     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
167     command     => 'service apache2 reload',
168     refreshonly => true,
169     require     =>  Package['apache2'],
170   }
171
172   apache2::config { 'puppet-ssl-key-pins':
173     content => template('apache2/ssl-key-pins.erb'),
174     notify  => Exec['service apache2 reload'],
175   }
176
177   apache2::config { 'local-scheduled-shutdown':
178     source => 'puppet:///modules/apache2/local-scheduled-shutdown',
179   }
180 }