static_mirror_web: replace the vhost_listen string with an Array of IP addresses
[mirror/dsa-puppet.git] / modules / roles / manifests / static_mirror_web.pp
index 7895a59..8c04475 100644 (file)
@@ -1,10 +1,18 @@
 # a static web mirror
+#
+# @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(
-  String  $vhost_listen = '*:80',
-  String  $vhost_listen_443 = '*:443',
+  Array[Stdlib::IP::Address] $listen_addr = [],
   Boolean $onion_service = false,
-  Optional[Stdlib::IP::Address] $onion_addr = undef,
 ) {
+  $_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
 
@@ -134,8 +142,9 @@ class roles::static_mirror_web(
 
 
   if $onion_service {
+    $onion_addr = filter_ipv4($listen_addr)[0]
     if ! $onion_addr {
-      fail("Do not have an onion_addr set for $::hostname.")
+      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_addr }