]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/portforwarder/templates/authorized_keys.erb
sudo: replace debbits by publicity
[dsa-puppet.git] / modules / portforwarder / templates / authorized_keys.erb
index c230bbc9c1c0c563f5d0fb78347c71ce687b91c0..063312a2f6008e5131fb8a05cce91dd14c0d04f2 100644 (file)
@@ -1,4 +1,16 @@
+##
+## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
+## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
+##
+
 <%=
+
+require 'digest/sha1'
+def get_local_ip_addr(host)
+       hash = Digest::SHA1.digest(host)
+       return '127.101.%d.%d'%[hash[0].ord, hash[1].ord]
+end
+
 def getportforwarderkey(host)
        key = nil
        begin
@@ -24,8 +36,8 @@ config.each_pair do |sourcehost, services|
 
        if allowed_ports.length > 0
                sshkey = getportforwarderkey(sourcehost)
-               remote_ip = keyinfo[sourcehost][0]['ipHostNumber'].join(',')
-               local_bind = '127.101.%d.%d'%[ (sourcehost.hash / 256 % 256), sourcehost.hash % 256 ]
+               remote_ip = scope.lookupvar('site::allnodeinfo')[sourcehost]['ipHostNumber'].join(',')
+               local_bind = get_local_ip_addr(sourcehost)
 
                lines << "# from #{sourcehost}"
                if sshkey.nil? or remote_ip.nil? or local_bind.nil?