debconf19 is not static just yet
[mirror/dsa-puppet.git] / modules / roles / manifests / static_mirror_web.pp
index 87e0f31..53ca839 100644 (file)
@@ -1,5 +1,18 @@
 # a static web mirror
-class roles::static_mirror_web {
+#
+# @param listen_addr IP addresses to have apache listen on
+# @param onion_service provide the onion service from this host
+class roles::static_mirror_web(
+  Array[Stdlib::IP::Address] $listen_addr = [],
+  Boolean $onion_service = false,
+) {
+  $_enclosed_addresses = empty($listen_addr) ? {
+    true    => ['*'],
+    default => enclose_ipv6($listen_addr),
+  }
+  $vhost_listen     = $_enclosed_addresses.map |$a| { "${a}:80"  } .join(' ')
+  $vhost_listen_443 = $_enclosed_addresses.map |$a| { "${a}:443" } .join(' ')
+
   include roles::static_mirror
   include roles::weblog_provider
 
@@ -15,24 +28,6 @@ class roles::static_mirror_web {
   apache2::module { 'deflate': }
   apache2::module { 'filter': }
 
-  $onion_v4_addr = $::hostname ? {
-    klecker    => '130.89.148.14',
-    mirror-isc => '149.20.4.15',
-    senfter    => '5.153.231.4',
-    default    => undef,
-  }
-  $vhost_listen = $::hostname ? {
-    klecker    => '130.89.148.14:80 [2001:67c:2564:a119::148:14]:80',
-    mirror-isc => '149.20.4.15:80 [2001:4f8:1:c::15]:80',
-    mirror-anu => '150.203.164.62:80 [2001:388:1034:2900::3e]:80',
-    default    => '*:80',
-  }
-  $vhost_listen_443 = $::hostname ? {
-    klecker    => '130.89.148.14:443 [2001:67c:2564:a119::148:14]:443',
-    mirror-isc => '149.20.4.15:443 [2001:4f8:1:c::15]:443',
-    mirror-anu => '150.203.164.62:443 [2001:388:1034:2900::3e]:443',
-    default    => '*:443',
-  }
   $redirect_vhosts = true
 
   apache2::config { 'local-static-vhost.conf':
@@ -43,39 +38,39 @@ class roles::static_mirror_web {
   }
 
   apache2::site { '010-planet.debian.org':
-    site    => 'planet.debian.org',
     ensure  => has_static_component('planet.debian.org') ? { true => 'present', false => 'absent' },
+    site    => 'planet.debian.org',
     content => template('roles/static-mirroring/vhost/planet.debian.org.erb'),
   }
 
   apache2::site { '010-lintian.debian.org':
-    site    => 'lintian.debian.org',
-    ensure  => absent,
+    ensure => absent,
+    site   => 'lintian.debian.org',
   }
 
   apache2::site { '010-static-vhosts-00-manpages':
-    site   => 'static-manpages.debian.org',
     ensure  => has_static_component('manpages.debian.org') ? { true => 'present', false => 'absent' },
+    site    => 'static-manpages.debian.org',
     content => template('roles/static-mirroring/vhost/manpages.debian.org.erb'),
   }
   apache2::site { '010-static-vhosts-simple':
-    site => 'static-vhosts-simple',
+    site    => 'static-vhosts-simple',
     content => template('roles/static-mirroring/vhost/static-vhosts-simple.erb'),
   }
 
   $wwwdo_server_name = 'www.debian.org'
   $wwwdo_document_root = '/srv/static.debian.org/mirrors/www.debian.org/cur'
   apache2::site { '005-www.debian.org':
-    site   => 'www.debian.org',
     ensure  => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
+    site    => 'www.debian.org',
     content => template('roles/apache-www.debian.org.erb'),
   }
 
   ssl::service { 'www.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debian.org' :
-    ensure  => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
-    notify  => Exec['service apache2 reload'],
-    key => true,
+    ensure => has_static_component('www.debian.org') ? { true => 'present', false => 'absent' },
+    notify => Exec['service apache2 reload'],
+    key    => true,
   }
 
   # do
@@ -95,8 +90,8 @@ class roles::static_mirror_web {
   ssl::service { 'manpages.debian.org'           : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'metadata-backend.ftp-master.debian.org':
     ensure => has_static_component('metadata.ftp-master.debian.org') ? { true => 'present', false => 'absent' },
-    notify  => Exec['service apache2 reload'],
-    key => true,
+    notify => Exec['service apache2 reload'],
+    key    => true,
   }
   ssl::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'onion.debian.org'              : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
@@ -130,7 +125,6 @@ class roles::static_mirror_web {
   ssl::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
-  ssl::service { 'debconf19.debconf.org'         : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
   ssl::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
@@ -146,71 +140,75 @@ class roles::static_mirror_web {
   ssl::service { 'www.debconf.org'               : ensure => 'ifstatic', notify  => Exec['service apache2 reload'], key => true, }
 
 
-  if has_role('static_mirror_onion') {
-    if ! $onion_v4_addr {
-      fail("Do not have an onion_v4_addr set for $::hostname.")
+  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?.")
     }
 
-    onion::service { 'd-i.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'dpl.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'dsa.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'rtc.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'www.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
+    onion::service { 'd-i.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'dpl.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'dsa.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'rtc.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'www.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
 
     # do
-    onion::service { 'appstream.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'backports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'bits.debian.org'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'blends.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'incoming.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'lintian.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'manpages.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'onion.debian.org'              : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'release.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'security-team.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'www.ports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
+    onion::service { 'appstream.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'backports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'bits.debian.org'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'blends.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'cdbuilder-logs.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'incoming.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'incoming.ports.debian.org'     : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'lintian.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'manpages.debian.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'mirror-master.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'onion.debian.org'              : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'openpgpkey.debian.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'release.debian.org'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'security-team.debian.org'      : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'www.ports.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
     # dn
-    onion::service { 'bootstrap.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debaday.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'micronews.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'mozilla.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'news.debian.net'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'timeline.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
+    onion::service { 'bootstrap.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debaday.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debdeltas.debian.net'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'micronews.debian.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'mozilla.debian.net'            : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'news.debian.net'               : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'timeline.debian.net'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'wnpp-by-tags.debian.net'       : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
     # dc
-    onion::service { '10years.debconf.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'es.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'fr.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
+    onion::service { '10years.debconf.org'           : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf0.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf1.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf16.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf17.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf18.debconf.org'         : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf2.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf3.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf4.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf5.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf6.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'debconf7.debconf.org'          : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'es.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'fr.debconf.org'                : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'miniconf10.debconf.org'        : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
 
     # non-SSL
-    onion::service { 'metadata.ftp-master.debian.org': ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
-    onion::service { 'planet.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_v4_addr }
+    onion::service { 'metadata.ftp-master.debian.org': ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
+    onion::service { 'planet.debian.org'             : ensure => 'ifstatic', port => 80, target_port => 80, target_address => $onion_addr }
   }
 
   file { '/srv/static.debian.org/puppet':
     ensure => directory,
-    mode   => '02755'
+    mode   => '2755'
   }
   file { '/srv/static.debian.org/puppet/disabled-service':
     ensure => directory,
-    mode   => '02755'
+    mode   => '2755'
   }
   file { '/srv/static.debian.org/puppet/disabled-service/503.html':
     source => 'puppet:///modules/roles/static-htdocs/disabled-service/503.html',