X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Froles%2Fmanifests%2Fdebug_mirror.pp;h=4975c41d47f54f1c3257611685e87bc7990452d4;hb=648c3f71395624c4e75004e78523c145b1e68ebf;hp=8c26b78a3decb636f33e9da54cd2d49dccc5b1fa;hpb=e9f6f03f48e386ff0de2a2ad7296a1d8e851fa06;p=mirror%2Fdsa-puppet.git diff --git a/modules/roles/manifests/debug_mirror.pp b/modules/roles/manifests/debug_mirror.pp index 8c26b78a3..4975c41d4 100644 --- a/modules/roles/manifests/debug_mirror.pp +++ b/modules/roles/manifests/debug_mirror.pp @@ -1,42 +1,56 @@ -class roles::debug_mirror { - include roles::archvsync_base +# a mirror for debug.debian.org +# +# @param listen_addr IP addresses to have apache listen on +# @param onion_service provide the onion service from this host +# @param healthcheck_name name to access this node in the health checker +class roles::debug_mirror( + Array[Stdlib::IP::Address] $listen_addr = [], + Boolean $onion_service = false, + Optional[String] $healthcheck_name = undef, +) { + include roles::archvsync_base + include apache2 - $mirror_basedir_prefix = hiera('role_config__mirrors.mirror_basedir_prefix') - $archive_root = "${mirror_basedir_prefix}debian-debug" + $_enclosed_addresses = empty($listen_addr) ? { + true => ['*'], + default => enclose_ipv6($listen_addr), + } + $vhost_listen = $_enclosed_addresses.map |$a| { "${a}:80" } .join(' ') - $listen_addresses = hiera('roles.debug_mirror') - .dig($::fqdn, 'listen-addresses') - .then |$a| { $a + [ '127.0.0.1:80', '[::1]:80' ] } - .lest || { ['*:80'] } + $mirror_basedir_prefix = hiera('role_config__mirrors.mirror_basedir_prefix') + $archive_root = "${mirror_basedir_prefix}debian-debug" - $vhost_listen = join($listen_addresses, ' ') - $onion_v4_addr = hiera("roles.debug_mirror", {}) - .dig($::fqdn, 'onion_v4_address') + apache2::site { '010-debug.mirrors.debian.org': + site => 'debug.mirrors.debian.org', + content => template('roles/apache-debug.mirrors.debian.org.erb'), + } - apache2::site { '010-debug.mirrors.debian.org': - site => 'debug.mirrors.debian.org', - content => template('roles/apache-debug.mirrors.debian.org.erb'), - } + if $onion_service { + $onion_addr = empty($listen_addr) ? { + true => $base::public_address, + default => filter_ipv4($listen_addr)[0] + } + if ! $onion_addr { + fail("Do not have a useable address for the onionservice on ${::hostname}. Is \$listen_addr empty or does it not have an IPv4 address?.") + } - if has_role('debug_mirror_onion') { - if ! $onion_v4_addr { - fail("Do not have an onion_v4_addr set for $::hostname.") - } + onion::service { 'debug.mirrors.debian.org': + port => 80, + target_port => 80, + target_address => $onion_addr, + } + } - onion::service { 'debug.mirrors.debian.org': - port => 80, - target_port => 80, - target_address => $onion_v4_addr, - } - } + Ferm::Rule::Simple <<| tag == 'ssh::server::from::ftp_master' |>> - $hosts_to_check = hiera('roles.debug_mirror', {}) - .filter |$h| { $h[1]['service-hostname'] } - .map |$h| { $h[1]['service-hostname'] } - roles::mirror_health { 'debug': - check_hosts => $hosts_to_check, - check_service => 'debug', - url => 'http://debug.backend.mirrors.debian.org/debian-debug/dists/sid-debug/Release', - health_url => 'http://debug.backend.mirrors.debian.org/_health', - } + $healthcheck_ensure = $healthcheck_name == undef ? { + true => 'absent', + default => 'present', + } + mirror_health::service { 'debug': + ensure => healthcheck_ensure, + this_host_service_name => $healthcheck_name, + url => 'http://debug.backend.mirrors.debian.org/debian-debug/dists/sid-debug/Release', + health_url => 'http://debug.backend.mirrors.debian.org/_health', + } }