X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=modules%2Fportforwarder%2Ftemplates%2Fauthorized_keys.erb;h=063312a2f6008e5131fb8a05cce91dd14c0d04f2;hb=a2aea510648d1d58789365a2d0b7bae76fcca37b;hp=985f367c7aaf3d094c06214b9b86ee094aad8ba7;hpb=09ab0b0f5d21744817de20b116633bd108272ab8;p=dsa-puppet.git diff --git a/modules/portforwarder/templates/authorized_keys.erb b/modules/portforwarder/templates/authorized_keys.erb index 985f367c..063312a2 100644 --- a/modules/portforwarder/templates/authorized_keys.erb +++ b/modules/portforwarder/templates/authorized_keys.erb @@ -4,6 +4,13 @@ ## <%= + +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 @@ -29,8 +36,8 @@ config.each_pair do |sourcehost, services| if allowed_ports.length > 0 sshkey = getportforwarderkey(sourcehost) - remote_ip = keyinfo[sourcehost]['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?