summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/trocla.rb
blob: b1a7b61cc3e48fa0e32515aa553a9192bcb1397d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Puppet::Parser::Functions
  newfunction(:trocla, :type => :rvalue, :doc => "
This will create or get a random password from the trocla storage.

Usage:

    $password_user1 = trocla(key,[format='plain'[,options={}]])

Means:

    $password_user1 = trocla('user1')

Create or get the plain text password for the key 'user1'

    $password_user2 = trocla('user2','mysql')

Create or get the mysql style sha1 hashed password.

    $options_user3 = { 'username' => 'user3' } # Due to a puppet bug
                                               # this needs to be assigned
                                               # like that.
    $password_user3 = trocla('user3','pgsql', $options_user3)

Options can also be passed as a yaml string:

    $password_user3 = trocla('user3','pgsql', \"username: 'user3'\")
  "
  ) do |*args|
    require File.dirname(__FILE__) + '/../../util/trocla_helper'

    Puppet::Util::TroclaHelper.trocla(:password,true,*args)
  end
end