Fix typo
[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
7         $vhost_listen = join([
8                 $::hostname ? {
9                         klecker    => '130.89.148.12:80 127.0.0.1:80 [2001:610:1908:b000::148:12]:80 [2001:67c:2564:a119::148:12]:80 [::1]:80',
10                         mirror-bytemark => '5.153.231.45:80 127.0.0.1:80 [2001:41c8:1000:21::21:45]:80 [::1]:80',
11                         mirror-isc => '149.20.4.15:80 127.0.0.1:80 [2001:4f8:1:c::15]:80 [::1]:80',
12                         mirror-conova => '217.196.149.232:80 127.0.0.1:80 [2a02:16a8:dc41:100::232]:80 [::1]:80',
13                         default => '*:80',
14                 },
15                 has_role('bgp') ? {
16                         true => '193.31.7.2:80 [2a02:158:ffff:deb::2]:80',
17                         default => '',
18                 }], ' ')
19         $onion_v4_addr = $::hostname ? {
20                 mirror-bytemark => '5.153.231.45',
21                 klecker    => '130.89.148.12',
22                 mirror-isc => '149.20.4.15',
23                 default    => undef,
24         }
25
26         apache2::site { '010-ftp.debian.org':
27                 site   => 'ftp.debian.org',
28                 content => template('roles/apache-ftp.debian.org.erb'),
29         }
30
31         if has_role('debian_mirror_onion') {
32                 if ! $onion_v4_addr {
33                         fail("Do not have an onion_v4_addr set for $::hostname.")
34                 }
35
36                 onion::service { 'ftp.debian.org':
37                         port => 80,
38                         target_port => 80,
39                         target_address => $onion_v4_addr,
40                 }
41         }
42
43         # roles is a list of hashes, which needs to be unpacked into a regular hash
44         $mirrors = hiera('roles.debian_mirror', [])
45         # unpack $mirrors and construct a hash
46         $m2 = Hash($mirrors.map |$h| { $h.map |$k, $v| { [$k, $v] }[0]})
47         $fastly_mirrors = $m2.filter |$h| { $h[1]['fastly-backend'] }
48         $hosts_to_check = $fastly_mirrors.map |$h| { $h[1]['service-hostname'] }
49
50         roles::mirror_health { 'ftp':
51                 check_hosts   => $hosts_to_check,
52                 check_service => 'ftp',
53                 url           => 'http://debian.backend.mirrors.debian.org/debian/dists/sid/Release',
54                 health_url    => 'http://debian.backend.mirrors.debian.org/_health',
55         }
56 }