2011-05-25 08:22:43 +02:00
|
|
|
# hash a string as mysql's "PASSWORD()" function would do it
|
|
|
|
require 'digest/sha1'
|
|
|
|
|
|
|
|
module Puppet::Parser::Functions
|
2012-02-09 20:26:00 +01:00
|
|
|
newfunction(:mysql_password, :type => :rvalue, :doc => <<-EOS
|
|
|
|
Returns the mysql password hash from the clear text password.
|
|
|
|
EOS
|
|
|
|
) do |args|
|
|
|
|
|
2013-07-10 05:11:41 +02:00
|
|
|
raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' +
|
2012-02-09 20:26:00 +01:00
|
|
|
"given (#{args.size} for 1)") if args.size != 1
|
2011-05-25 08:22:43 +02:00
|
|
|
|
2012-02-09 20:26:00 +01:00
|
|
|
'*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase
|
|
|
|
end
|
|
|
|
end
|