let ports mirrors get triggered from syncproxies
[mirror/dsa-puppet.git] / modules / roles / manifests / ports_mirror.pp
1 # a mirror of ports.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::ports_mirror(
6   Array[Stdlib::IP::Address] $listen_addr = [],
7   Boolean $onion_service = false,
8 ) {
9   include roles::archvsync_base
10
11   include apache2
12
13   $_enclosed_addresses = empty($listen_addr) ? {
14     true    => ['*'],
15     default => enclose_ipv6($listen_addr),
16   }
17   $vhost_listen = $_enclosed_addresses.map |$a| { "${a}:80" } .join(' ')
18
19   $mirror_basedir_prefix = hiera('role_config__mirrors.mirror_basedir_prefix')
20   $archive_root = "${mirror_basedir_prefix}debian-ports"
21
22   apache2::site { '010-ftp.ports.debian.org':
23     site    => 'ftp.ports.debian.org',
24     content => template('roles/apache-ftp.ports.debian.org.erb'),
25   }
26
27   if $onion_service {
28     $onion_addr = empty($listen_addr) ? {
29       true    => $base::public_address,
30       default => filter_ipv4($listen_addr)[0]
31     }
32     if ! $onion_addr {
33       fail("Do not have a useable address for the onionservice on ${::hostname}.  Is \$listen_addr empty or does it not have an IPv4 address?.")
34     }
35
36     onion::service { 'ftp.ports.debian.org':
37       port           => 80,
38       target_port    => 80,
39       target_address => $onion_addr,
40     }
41   }
42
43   Ferm::Rule::Simple <<| tag == 'ssh::server::from::syncproxy' |>>
44 }