Move the non-roles static_base and static_srvdir to static/<foo>
[mirror/dsa-puppet.git] / modules / roles / manifests / static_mirror.pp
1 # a static mirror
2 #
3 # this receives pushes from the master and then usually serves the content to the public
4 class roles::static_mirror {
5   include roles::static::base
6   include roles::static::srvdir
7   include apache2::expires
8   include apache2::rewrite
9
10   package { 'libapache2-mod-geoip': ensure => installed, }
11   package { 'geoip-database': ensure => installed, }
12
13   include apache2::ssl
14   apache2::module { 'include': }
15   apache2::module { 'geoip': require => [Package['libapache2-mod-geoip'], Package['geoip-database']]; }
16   apache2::module { 'deflate': }
17   apache2::module { 'filter': }
18
19   file { '/usr/local/bin/static-mirror-run':
20     source => 'puppet:///modules/roles/static-mirroring/static-mirror-run',
21     mode   => '0555',
22   }
23
24   file { '/usr/local/bin/static-mirror-run-all':
25     source => 'puppet:///modules/roles/static-mirroring/static-mirror-run-all',
26     mode   => '0555',
27   }
28
29   file { '/etc/cron.d/puppet-static-mirror': ensure => absent, }
30   concat::fragment { 'dsa-puppet-stuff--static-mirror':
31     target => '/etc/cron.d/dsa-puppet-stuff',
32     content  => @(EOF)
33       @reboot staticsync sleep 60; chronic static-mirror-run-all
34       | EOF
35   }
36
37   $onion_v4_addr = $::hostname ? {
38     klecker    => '130.89.148.14',
39     mirror-isc => '149.20.4.15',
40     senfter    => '5.153.231.4',
41     default    => undef,
42   }
43   $vhost_listen = $::hostname ? {
44     klecker    => '130.89.148.14:80 [2001:67c:2564:a119::148:14]:80',
45     mirror-isc => '149.20.4.15:80 [2001:4f8:1:c::15]:80',
46     mirror-anu => '150.203.164.62:80 [2001:388:1034:2900::3e]:80',
47     default    => '*:80',
48   }
49   $vhost_listen_443 = $::hostname ? {
50     klecker    => '130.89.148.14:443 [2001:67c:2564:a119::148:14]:443',
51     mirror-isc => '149.20.4.15:443 [2001:4f8:1:c::15]:443',
52     mirror-anu => '150.203.164.62:443 [2001:388:1034:2900::3e]:443',
53     default    => '*:443',
54   }
55   $redirect_vhosts = true
56
57   apache2::config { 'local-static-vhost.conf':
58     ensure => absent,
59   }
60   apache2::config { 'local-static-vhost':
61     content => template('roles/static-mirroring/static-vhost.conf.erb'),
62   }
63
64   apache2::site { '010-planet.debian.org':
65     site    => 'planet.debian.org',
66     ensure  => has_static_component('planet.debian.org') ? { true => 'present', false => 'absent' },
67     content => template('roles/static-mirroring/vhost/planet.debian.org.erb'),
68   }
69
70   apache2::site { '010-lintian.debian.org':
71     site    => 'lintian.debian.org',
72     ensure  => absent,
73   }
74
75   apache2::site { '010-static-vhosts-00-manpages':
76     site   => 'static-manpages.debian.org',
77     ensure  => has_static_component('manpages.debian.org') ? { true => 'present', false => 'absent' },
78     content => template('roles/static-mirroring/vhost/manpages.debian.org.erb'),
79   }
80   apache2::site { '010-static-vhosts-simple':
81     site => 'static-vhosts-simple',
82     content => template('roles/static-mirroring/vhost/static-vhosts-simple.erb'),
83   }
84
85   $wwwdo_server_name = 'www.debian.org'
86   $wwwdo_document_root = '/srv/static.debian.org/mirrors/www.debian.org/cur'
87   apache2::site { '005-www.debian.org':
88     site   => 'www.debian.org',
89     ensure  => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
90     content => template('roles/apache-www.debian.org.erb'),
91   }
92
93   ssl::service { 'www.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
94   ssl::service { 'debian.org' :
95     ensure  => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
96     notify  => Exec['service apache2 reload'],
97     key => true,
98   }
99
100   # do
101   ssl::service { 'appstream.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
102   ssl::service { 'backports.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
103   ssl::service { 'bits.debian.org'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
104   ssl::service { 'blends.debian.org'             : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
105   ssl::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
106   ssl::service { 'd-i.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
107   ssl::service { 'deb.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
108   ssl::service { 'dpl.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
109   ssl::service { 'dsa.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
110   ssl::service { 'incoming.debian.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
111   ssl::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
112   ssl::service { 'lintian.debian.org'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
113   ssl::service { 'lists.alioth.debian.org'       : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
114   ssl::service { 'manpages.debian.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
115   ssl::service { 'metadata-backend.ftp-master.debian.org':
116     ensure => has_static_component('metadata.ftp-master.debian.org') ? { true => 'present', false => 'absent' },
117     notify  => Exec['service apache2 reload'],
118     key => true,
119   }
120   ssl::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
121   ssl::service { 'onion.debian.org'              : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
122   ssl::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
123   ssl::service { 'pkg-ruby-extras.alioth.debian.org' : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
124   ssl::service { 'planet-backend.debian.org'     :
125     ensure => has_static_component('planet.debian.org') ? { true => 'present', false => 'absent' },
126     notify => Exec['service apache2 reload'],
127     key    => true,
128   }
129   ssl::service { 'release.debian.org'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
130   ssl::service { 'rtc.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
131   ssl::service { 'security-team.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
132   ssl::service { 'www.ports.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
133   # dn
134   ssl::service { 'bootstrap.debian.net'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
135   ssl::service { 'debaday.debian.net'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
136   ssl::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
137   ssl::service { 'micronews.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
138   ssl::service { 'mozilla.debian.net'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
139   ssl::service { 'news.debian.net'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
140   ssl::service { 'sources.debian.net'            : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
141   ssl::service { 'timeline.debian.net'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
142   ssl::service { 'video.debian.net'              : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
143   ssl::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
144   # dc
145   ssl::service { 'debconf.org'                   : ensure => 'present', notify  => Exec['service apache2 reload'], key => true, }
146   ssl::service { '10years.debconf.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
147   ssl::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
148   ssl::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
149   ssl::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
150   ssl::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
151   ssl::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
152   ssl::service { 'debconf19.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
153   ssl::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
154   ssl::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
155   ssl::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
156   ssl::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
157   ssl::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
158   ssl::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
159   ssl::service { 'es.debconf.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
160   ssl::service { 'fr.debconf.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
161   ssl::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
162   ssl::service { 'video.debconf.org'             : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
163   ssl::service { 'wiki.debconf.org'              : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
164   include apache2::proxy_http
165   ssl::service { 'www.debconf.org'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
166
167   if has_role('static_mirror_onion') {
168     if ! $onion_v4_addr {
169       fail("Do not have an onion_v4_addr set for $::hostname.")
170     }
171
172     onion::service { 'd-i.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
173     onion::service { 'dpl.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
174     onion::service { 'dsa.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
175     onion::service { 'rtc.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
176     onion::service { 'www.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
177
178     # do
179     onion::service { 'appstream.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
180     onion::service { 'backports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
181     onion::service { 'bits.debian.org'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
182     onion::service { 'blends.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
183     onion::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
184     onion::service { 'incoming.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
185     onion::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
186     onion::service { 'lintian.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
187     onion::service { 'manpages.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
188     onion::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
189     onion::service { 'onion.debian.org'              : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
190     onion::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
191     onion::service { 'release.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
192     onion::service { 'security-team.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
193     onion::service { 'www.ports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
194     # dn
195     onion::service { 'bootstrap.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
196     onion::service { 'debaday.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
197     onion::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
198     onion::service { 'micronews.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
199     onion::service { 'mozilla.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
200     onion::service { 'news.debian.net'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
201     onion::service { 'timeline.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
202     onion::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
203     # dc
204     onion::service { '10years.debconf.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
205     onion::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
206     onion::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
207     onion::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
208     onion::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
209     onion::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
210     onion::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
211     onion::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
212     onion::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
213     onion::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
214     onion::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
215     onion::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
216     onion::service { 'es.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
217     onion::service { 'fr.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
218     onion::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
219
220     # non-SSL
221     onion::service { 'metadata.ftp-master.debian.org': ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
222     onion::service { 'planet.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
223   }
224
225   file { '/srv/static.debian.org/puppet':
226     ensure => directory,
227     mode   => '02755'
228   }
229   file { '/srv/static.debian.org/puppet/disabled-service':
230     ensure => directory,
231     mode   => '02755'
232   }
233   file { '/srv/static.debian.org/puppet/disabled-service/503.html':
234     source => 'puppet:///modules/roles/static-htdocs/disabled-service/503.html',
235   }
236
237   ssl::service { 'archive.debian.net': ensure => present, notify  => Exec['service apache2 reload'], key => true, }
238   file { '/srv/static.debian.org/puppet/archive.debian.net':
239     ensure => absent,
240   }
241   file { '/srv/static.debian.org/puppet/archive.debian.net/503.html':
242     ensure => absent,
243   }
244
245   ssl::service { 'cdimage.debian.org': ensure => present, notify => Exec['service apache2 reload'], key => true, }
246   file { '/srv/static.debian.org/puppet/cdimage.debian.org':
247     ensure => directory,
248   }
249   file { '/srv/static.debian.org/puppet/cdimage.debian.org/503.html':
250     source => 'puppet:///modules/roles/static-htdocs/cdimage-maintenance.html',
251   }
252 }