# puppet/parser/functions/cprt_ssh_aliases.rb
module Puppet::Parser::Functions
  newfunction(:cprt_ssh_aliases, :type => :rvalue) do 
    bar = []
    fqdn = lookupvar('cprt_ipaddresses').downcase()
    lookupvar('cprt_ipaddresses').split(',').each { |ipaddr|
      addr = Socket.gethostbyname(ipaddr) # convert IP address to real thing
      tmp = Socket.gethostbyaddr(addr[3], addr[2])
      host = Socket.gethostbyaddr(tmp[3], tmp[2])
      #name = host[0].downcase()
      bar << ipaddr
      host[1].each { |h| bar << h unless h == fqdn }
    }
    return bar
  end
end

Add a code snippet to your website: www.paste.org