summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README5
-rw-r--r--lib/puppet/parser/functions/trocla.rb26
-rw-r--r--lib/puppet/parser/functions/trocla_get.rb23
3 files changed, 49 insertions, 5 deletions
diff --git a/README b/README
index 89d397a..f51c4de 100644
--- a/README
+++ b/README
@@ -1,4 +1,7 @@
trocla
This is the trocla module. It provides the necessary function to query
-trocla from puppet, as well as a puppet class to setup things on the puppetmaster.
+trocla from puppet, as well as a puppet class to setup things on the
+puppetmaster.
+
+For more information about trocla visit: https://github.com/duritong/trocla
diff --git a/lib/puppet/parser/functions/trocla.rb b/lib/puppet/parser/functions/trocla.rb
index 9fa06bb..487d1fd 100644
--- a/lib/puppet/parser/functions/trocla.rb
+++ b/lib/puppet/parser/functions/trocla.rb
@@ -1,7 +1,29 @@
module Puppet::Parser::Functions
- newfunction(:trocla, :type => :rvalue) do |*args|
+ 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)
+ "
+ ) do |*args|
require File.dirname(__FILE__) + '/../../util/trocla_helper'
Puppet::Util::TroclaHelper.trocla(:password,true,*args)
end
-end \ No newline at end of file
+end
diff --git a/lib/puppet/parser/functions/trocla_get.rb b/lib/puppet/parser/functions/trocla_get.rb
index ed8eeab..01c4e01 100644
--- a/lib/puppet/parser/functions/trocla_get.rb
+++ b/lib/puppet/parser/functions/trocla_get.rb
@@ -1,9 +1,28 @@
module Puppet::Parser::Functions
- newfunction(:trocla_get, :type => :rvalue) do |*args|
+ newfunction(:trocla_get, :type => :rvalue, :doc => "
+ This will only get an already stored password from the trocla storage.
+
+Usage:
+
+ $password_user1 = trocla_get(key,[format='plain'])
+
+Means:
+
+ $password_user1 = trocla('user1')
+
+Get the plain text password for the key 'user1'
+
+ $password_user2 = trocla_get('user2','mysql')
+
+Get the mysql style sha1 hashed password.
+
+It will raise a parse error if the password haven't yet been stored in trocla.
+"
+ ) do |*args|
require File.dirname(__FILE__) + '/../../util/trocla_helper'
if (answer=Puppet::Util::TroclaHelper.trocla(:get_password,false,*args)).nil?
raise(Puppet::ParseError, "No password for key,format #{args.flatten.inspect} found!")
end
answer
end
-end \ No newline at end of file
+end