onion for www
authorPeter Palfrader <peter@palfrader.org>
Fri, 29 Jul 2016 16:49:59 +0000 (16:49 +0000)
committerPeter Palfrader <peter@palfrader.org>
Fri, 29 Jul 2016 16:49:59 +0000 (16:49 +0000)
modules/puppetmaster/lib/puppet/parser/functions/onion_global_service_hostname.rb [new file with mode: 0644]
modules/roles/templates/apache-www.debian.org.erb

diff --git a/modules/puppetmaster/lib/puppet/parser/functions/onion_global_service_hostname.rb b/modules/puppetmaster/lib/puppet/parser/functions/onion_global_service_hostname.rb
new file mode 100644 (file)
index 0000000..dce7740
--- /dev/null
@@ -0,0 +1,23 @@
+# 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:
index 5c9d125..195be9f 100644 (file)
    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