onion for www
[mirror/dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / onion_global_service_hostname.rb
1 # This function returns the .onion name for a given service name on Debian's onionbalance instance
2 # for this, it reads /srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml
3 # this comes from the onionbalance-host, via puppet's storedconf
4 #
5 module Puppet::Parser::Functions
6   newfunction(:onion_global_service_hostname, :type => :rvalue) do |args|
7     servicename = args.shift()
8
9     fn = '/srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml'
10     unless File.exist?(fn)
11       return false
12     end
13
14     facts = IO.read(fn)
15
16     require 'json'
17     parsed = JSON.parse(facts)
18     return parsed[servicename]
19   end
20 end
21 # vim:set ts=2:
22 # vim:set et:
23 # vim:set shiftwidth=2: