debconf19 is not static just yet
[mirror/dsa-puppet.git] / modules / roles / manifests / static_mirror_web.pp
1 # a static web mirror
2 #
3 # @param listen_addr IP addresses to have apache listen on
4 # @param onion_service provide the onion service from this host
5 class roles::static_mirror_web(
6   Array[Stdlib::IP::Address] $listen_addr = [],
7   Boolean $onion_service = false,
8 ) {
9   $_enclosed_addresses = empty($listen_addr) ? {
10     true    => ['*'],
11     default => enclose_ipv6($listen_addr),
12   }
13   $vhost_listen     = $_enclosed_addresses.map |$a| { "${a}:80"  } .join(' ')
14   $vhost_listen_443 = $_enclosed_addresses.map |$a| { "${a}:443" } .join(' ')
15
16   include roles::static_mirror
17   include roles::weblog_provider
18
19   include apache2::expires
20   include apache2::rewrite
21
22   package { 'libapache2-mod-geoip': ensure => installed, }
23   package { 'geoip-database': ensure => installed, }
24
25   include apache2::ssl
26   apache2::module { 'include': }
27   apache2::module { 'geoip': require => [Package['libapache2-mod-geoip'], Package['geoip-database']]; }
28   apache2::module { 'deflate': }
29   apache2::module { 'filter': }
30
31   $redirect_vhosts = true
32
33   apache2::config { 'local-static-vhost.conf':
34     ensure => absent,
35   }
36   apache2::config { 'local-static-vhost':
37     content => template('roles/static-mirroring/static-vhost.conf.erb'),
38   }
39
40   apache2::site { '010-planet.debian.org':
41     ensure  => has_static_component('planet.debian.org') ? { true => 'present', false => 'absent' },
42     site    => 'planet.debian.org',
43     content => template('roles/static-mirroring/vhost/planet.debian.org.erb'),
44   }
45
46   apache2::site { '010-lintian.debian.org':
47     ensure => absent,
48     site   => 'lintian.debian.org',
49   }
50
51   apache2::site { '010-static-vhosts-00-manpages':
52     ensure  => has_static_component('manpages.debian.org') ? { true => 'present', false => 'absent' },
53     site    => 'static-manpages.debian.org',
54     content => template('roles/static-mirroring/vhost/manpages.debian.org.erb'),
55   }
56   apache2::site { '010-static-vhosts-simple':
57     site    => 'static-vhosts-simple',
58     content => template('roles/static-mirroring/vhost/static-vhosts-simple.erb'),
59   }
60
61   $wwwdo_server_name = 'www.debian.org'
62   $wwwdo_document_root = '/srv/static.debian.org/mirrors/www.debian.org/cur'
63   apache2::site { '005-www.debian.org':
64     ensure  => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
65     site    => 'www.debian.org',
66     content => template('roles/apache-www.debian.org.erb'),
67   }
68
69   ssl::service { 'www.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
70   ssl::service { 'debian.org' :
71     ensure => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
72     notify => Exec['service apache2 reload'],
73     key    => true,
74   }
75
76   # do
77   ssl::service { 'appstream.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
78   ssl::service { 'backports.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
79   ssl::service { 'bits.debian.org'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
80   ssl::service { 'blends.debian.org'             : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
81   ssl::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
82   ssl::service { 'd-i.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
83   ssl::service { 'deb.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
84   ssl::service { 'dpl.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
85   ssl::service { 'dsa.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
86   ssl::service { 'incoming.debian.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
87   ssl::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
88   ssl::service { 'lintian.debian.org'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
89   ssl::service { 'lists.alioth.debian.org'       : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
90   ssl::service { 'manpages.debian.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
91   ssl::service { 'metadata-backend.ftp-master.debian.org':
92     ensure => has_static_component('metadata.ftp-master.debian.org') ? { true => 'present', false => 'absent' },
93     notify => Exec['service apache2 reload'],
94     key    => true,
95   }
96   ssl::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
97   ssl::service { 'onion.debian.org'              : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
98   ssl::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
99   ssl::service { 'pkg-ruby-extras.alioth.debian.org' : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
100   ssl::service { 'planet-backend.debian.org'     :
101     ensure => has_static_component('planet.debian.org') ? { true => 'present', false => 'absent' },
102     notify => Exec['service apache2 reload'],
103     key    => true,
104   }
105   ssl::service { 'release.debian.org'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
106   ssl::service { 'rtc.debian.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true }
107   ssl::service { 'security-team.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
108   ssl::service { 'www.ports.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
109   # dn
110   ssl::service { 'bootstrap.debian.net'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
111   ssl::service { 'debaday.debian.net'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
112   ssl::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
113   ssl::service { 'micronews.debian.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
114   ssl::service { 'mozilla.debian.net'            : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
115   ssl::service { 'news.debian.net'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
116   ssl::service { 'sources.debian.net'            : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
117   ssl::service { 'timeline.debian.net'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
118   ssl::service { 'video.debian.net'              : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
119   ssl::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
120   # dc
121   ssl::service { 'debconf.org'                   : ensure => 'present', notify  => Exec['service apache2 reload'], key => true, }
122   ssl::service { '10years.debconf.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
123   ssl::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
124   ssl::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
125   ssl::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
126   ssl::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
127   ssl::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
128   ssl::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
129   ssl::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
130   ssl::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
131   ssl::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
132   ssl::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
133   ssl::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
134   ssl::service { 'es.debconf.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
135   ssl::service { 'fr.debconf.org'                : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
136   ssl::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
137   ssl::service { 'video.debconf.org'             : ensure => 'present',  notify  => Exec['service apache2 reload'], key => true, }
138   ssl::service { 'wiki.debconf.org'              : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
139   include apache2::proxy_http
140   ssl::service { 'www.debconf.org'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
141
142
143   if $onion_service {
144     $onion_addr = empty($listen_addr) ? {
145       true    => $base::public_address,
146       default => filter_ipv4($listen_addr)[0]
147     }
148     if ! $onion_addr {
149       fail("Do not have a useable address for the onionservice on ${::hostname}.  Is \$listen_addr empty or does it not have an IPv4 address?.")
150     }
151
152     onion::service { 'd-i.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
153     onion::service { 'dpl.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
154     onion::service { 'dsa.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
155     onion::service { 'rtc.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
156     onion::service { 'www.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
157
158     # do
159     onion::service { 'appstream.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
160     onion::service { 'backports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
161     onion::service { 'bits.debian.org'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
162     onion::service { 'blends.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
163     onion::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
164     onion::service { 'incoming.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
165     onion::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
166     onion::service { 'lintian.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
167     onion::service { 'manpages.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
168     onion::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
169     onion::service { 'onion.debian.org'              : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
170     onion::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
171     onion::service { 'release.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
172     onion::service { 'security-team.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
173     onion::service { 'www.ports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
174     # dn
175     onion::service { 'bootstrap.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
176     onion::service { 'debaday.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
177     onion::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
178     onion::service { 'micronews.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
179     onion::service { 'mozilla.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
180     onion::service { 'news.debian.net'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
181     onion::service { 'timeline.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
182     onion::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
183     # dc
184     onion::service { '10years.debconf.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
185     onion::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
186     onion::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
187     onion::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
188     onion::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
189     onion::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
190     onion::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
191     onion::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
192     onion::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
193     onion::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
194     onion::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
195     onion::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
196     onion::service { 'es.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
197     onion::service { 'fr.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
198     onion::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
199
200     # non-SSL
201     onion::service { 'metadata.ftp-master.debian.org': ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
202     onion::service { 'planet.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
203   }
204
205   file { '/srv/static.debian.org/puppet':
206     ensure => directory,
207     mode   => '2755'
208   }
209   file { '/srv/static.debian.org/puppet/disabled-service':
210     ensure => directory,
211     mode   => '2755'
212   }
213   file { '/srv/static.debian.org/puppet/disabled-service/503.html':
214     source => 'puppet:///modules/roles/static-htdocs/disabled-service/503.html',
215   }
216
217   ssl::service { 'archive.debian.net': ensure => present, notify  => Exec['service apache2 reload'], key => true, }
218   file { '/srv/static.debian.org/puppet/archive.debian.net':
219     ensure => absent,
220   }
221   file { '/srv/static.debian.org/puppet/archive.debian.net/503.html':
222     ensure => absent,
223   }
224
225   ssl::service { 'cdimage.debian.org': ensure => present, notify => Exec['service apache2 reload'], key => true, }
226   file { '/srv/static.debian.org/puppet/cdimage.debian.org':
227     ensure => directory,
228   }
229   file { '/srv/static.debian.org/puppet/cdimage.debian.org/503.html':
230     source => 'puppet:///modules/roles/static-htdocs/cdimage-maintenance.html',
231   }
232 }