summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/trocla.rb4
-rw-r--r--lib/puppet/util/trocla_helper.rb7
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/trocla.rb b/lib/puppet/parser/functions/trocla.rb
index 487d1fd..e042872 100644
--- a/lib/puppet/parser/functions/trocla.rb
+++ b/lib/puppet/parser/functions/trocla.rb
@@ -20,6 +20,10 @@ Create or get the mysql style sha1 hashed password.
# 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'
diff --git a/lib/puppet/util/trocla_helper.rb b/lib/puppet/util/trocla_helper.rb
index 374d538..58ccf9c 100644
--- a/lib/puppet/util/trocla_helper.rb
+++ b/lib/puppet/util/trocla_helper.rb
@@ -17,7 +17,12 @@ module Puppet::Util::TroclaHelper
format = args[1] || 'plain'
options = args[2] || {}
- configfile = File.join(File.dirname(Puppet.settings[:config]), 'troclarc.yaml')
+ if options.is_a?(String)
+ require 'yaml'
+ options = YAML.load(options)
+ end
+
+ configfile = File.join(File.dirname(Puppet.settings[:config]), "troclarc.yaml")
raise(Puppet::ParseError, "Trocla config file #{configfile} is not readable") unless File.exist?(configfile)
raise(Puppet::ParseError, "You need rubygems to use Trocla") unless Puppet.features.rubygems?