Add actual postgresl module from puppetlabs
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / lib / puppet / parser / functions / postgresql_password.rb
1 # hash a string as mysql's "PASSWORD()" function would do it
2 require 'digest/md5'
3
4 module Puppet::Parser::Functions
5   newfunction(:postgresql_password, :type => :rvalue, :doc => <<-EOS
6     Returns the postgresql password hash from the clear text username / password.
7     EOS
8   ) do |args|
9
10     raise(Puppet::ParseError, "postgresql_password(): Wrong number of arguments " +
11       "given (#{args.size} for 2)") if args.size != 2
12
13     username = args[0]
14     password = args[1]
15
16     'md5' + Digest::MD5.hexdigest(password + username)
17   end
18 end