2e22aaa16e77683ab283fcc470db3074f6b57444
[mirror/dsa-puppet.git] / modules / roles / manifests / debian_mirror.pp
1 class roles::debian_mirror {
2         include roles::archvsync_base
3
4         $mirror_basedir_prefix = hiera('role_config__mirrors.mirror_basedir_prefix')
5         $archive_root = "${mirror_basedir_prefix}debian"
6         $listen_addresses = hiera('roles.debian_mirror')
7                 .dig($::fqdn, 'listen-addresses')
8                 .then |$a| { $a + [ '127.0.0.1:80', '[::1]:80' ] }
9                 .lest || { ['*:80'] }
10
11         $vhost_listen = join([
12                 *$listen_addresses,
13                 has_role('bgp') ? {
14                         true => '193.31.7.2:80 [2a02:158:ffff:deb::2]:80',
15                         default => '',
16                 }], ' ')
17         $onion_v4_addr = $::hostname ? {
18                 mirror-bytemark => '5.153.231.45',
19                 klecker    => '130.89.148.12',
20                 mirror-isc => '149.20.4.15',
21                 default    => undef,
22         }
23
24         apache2::site { '010-ftp.debian.org':
25                 site   => 'ftp.debian.org',
26                 content => template('roles/apache-ftp.debian.org.erb'),
27         }
28
29         if has_role('debian_mirror_onion') {
30                 if ! $onion_v4_addr {
31                         fail("Do not have an onion_v4_addr set for $::hostname.")
32                 }
33
34                 onion::service { 'ftp.debian.org':
35                         port => 80,
36                         target_port => 80,
37                         target_address => $onion_v4_addr,
38                 }
39         }
40
41         $mirrors = hiera('roles.debian_mirror', {})
42         $fastly_mirrors = $mirrors.filter |$h| { $h[1]['fastly-backend'] }
43         $hosts_to_check = $fastly_mirrors.map |$h| { $h[1]['service-hostname'] }
44
45         roles::mirror_health { 'ftp':
46                 check_hosts   => $hosts_to_check,
47                 check_service => 'ftp',
48                 url           => 'http://debian.backend.mirrors.debian.org/debian/dists/sid/Release',
49                 health_url    => 'http://debian.backend.mirrors.debian.org/_health',
50         }
51 }