8c26b78a3decb636f33e9da54cd2d49dccc5b1fa
[mirror/dsa-puppet.git] / modules / roles / manifests / debug_mirror.pp
1 class roles::debug_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-debug"
6
7         $listen_addresses = hiera('roles.debug_mirror')
8                 .dig($::fqdn, 'listen-addresses')
9                 .then |$a| { $a + [ '127.0.0.1:80', '[::1]:80' ] }
10                 .lest || { ['*:80'] }
11
12         $vhost_listen = join($listen_addresses, ' ')
13         $onion_v4_addr = hiera("roles.debug_mirror", {})
14                 .dig($::fqdn, 'onion_v4_address')
15
16         apache2::site { '010-debug.mirrors.debian.org':
17                 site   => 'debug.mirrors.debian.org',
18                 content => template('roles/apache-debug.mirrors.debian.org.erb'),
19         }
20
21         if has_role('debug_mirror_onion') {
22                 if ! $onion_v4_addr {
23                         fail("Do not have an onion_v4_addr set for $::hostname.")
24                 }
25
26                 onion::service { 'debug.mirrors.debian.org':
27                         port => 80,
28                         target_port => 80,
29                         target_address => $onion_v4_addr,
30                 }
31         }
32
33         $hosts_to_check = hiera('roles.debug_mirror', {})
34                 .filter |$h| { $h[1]['service-hostname'] }
35                 .map |$h| { $h[1]['service-hostname'] }
36         roles::mirror_health { 'debug':
37                 check_hosts     => $hosts_to_check,
38                 check_service   => 'debug',
39                 url             => 'http://debug.backend.mirrors.debian.org/debian-debug/dists/sid-debug/Release',
40                 health_url      => 'http://debug.backend.mirrors.debian.org/_health',
41         }
42 }