--- /dev/null
+# This function returns the .onion name for a given service name on Debian's onionbalance instance
+# for this, it reads /srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml
+# this comes from the onionbalance-host, via puppet's storedconf
+#
+module Puppet::Parser::Functions
+ newfunction(:onion_global_service_hostname, :type => :rvalue) do |args|
+ servicename = args.shift()
+
+ fn = '/srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml'
+ unless File.exist?(fn)
+ return false
+ end
+
+ facts = IO.read(fn)
+
+ require 'json'
+ parsed = JSON.parse(facts)
+ return parsed[servicename]
+ end
+end
+# vim:set ts=2:
+# vim:set et:
+# vim:set shiftwidth=2:
ServerName debian.org
ServerAdmin webmaster@debian.org
+ <% if scope.function_onion_global_service_hostname(['www.debian.org']) -%>
+ ServerAlias <%= scope.function_onion_global_service_hostname(['www.debian.org']) %>
+ <% end %>
+
ServerAlias www.at.debian.org
ServerAlias www.au.debian.org
ServerAlias www.bg.debian.org