debug_mirror -> hiera role, first step
[mirror/dsa-puppet.git] / modules / roles / manifests / debug_mirror.pp
1 # a mirror for debug.debian.org
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::debug_mirror(
6   Array[Stdlib::IP::Address] $listen_addr = [],
7   Boolean $onion_service = false,
8 ) {
9   include roles::archvsync_base
10   include apache2
11
12   $_enclosed_addresses = empty($listen_addr) ? {
13     true    => ['*'],
14     default => enclose_ipv6($listen_addr),
15   }
16   $vhost_listen = $_enclosed_addresses.map |$a| { "${a}:80" } .join(' ')
17
18   $mirror_basedir_prefix = hiera('role_config__mirrors.mirror_basedir_prefix')
19   $archive_root = "${mirror_basedir_prefix}debian-debug"
20
21   apache2::site { '010-debug.mirrors.debian.org':
22     site    => 'debug.mirrors.debian.org',
23     content => template('roles/apache-debug.mirrors.debian.org.erb'),
24   }
25
26   if $onion_service {
27     $onion_addr = empty($listen_addr) ? {
28       true    => $base::public_address,
29       default => filter_ipv4($listen_addr)[0]
30     }
31     if ! $onion_addr {
32       fail("Do not have a useable address for the onionservice on ${::hostname}.  Is \$listen_addr empty or does it not have an IPv4 address?.")
33     }
34
35     onion::service { 'debug.mirrors.debian.org':
36       port           => 80,
37       target_port    => 80,
38       target_address => $onion_addr,
39     }
40   }
41
42   Ferm::Rule::Simple <<| tag == 'ssh::server::from::ftp_master' |>>
43
44   $hosts_to_check = hiera('roles.debug_mirror', {})
45     .map |$h| { $h[1]['service-hostname'] }
46   roles::mirror_health { 'debug':
47     check_hosts   => $hosts_to_check,
48     check_service => 'debug',
49     url           => 'http://debug.backend.mirrors.debian.org/debian-debug/dists/sid-debug/Release',
50     health_url    => 'http://debug.backend.mirrors.debian.org/_health',
51   }
52 }