2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
7 def getportforwarderkey(host)
10 facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read)
11 return facts.values['portforwarder_key']
19 config = YAML.load(File.open('/etc/puppet/modules/portforwarder/misc/config.yaml').read)
20 config.each_pair do |sourcehost, services|
23 ##lines << "# sourcehost is #{sourcehost}"
24 services.each do |service|
25 ##lines << "# targethost is #{service['target_host']}, my hostname #{hostname}, fqdn is #{fqdn}"
26 next if service['target_host'] != fqdn
27 allowed_ports << service['target_port'] if service['target_port']
30 if allowed_ports.length > 0
31 sshkey = getportforwarderkey(sourcehost)
32 remote_ip = scope.lookupvar('site::allnodeinfo')[sourcehost]['ipHostNumber'].join(',')
33 local_bind = '127.101.%d.%d'%[ (sourcehost.hash / 256 % 256), sourcehost.hash % 256 ]
35 lines << "# from #{sourcehost}"
36 if sshkey.nil? or remote_ip.nil? or local_bind.nil?
37 lines << "# insufficient config values"
39 command = "/usr/bin/portforwarder-ssh-wrap #{sourcehost} #{local_bind} #{allowed_ports.join(' ')}"
40 lines << "from=\"#{remote_ip}\",command=\"#{command}\",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding #{sshkey}"