summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/trocla_set.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/trocla_set.rb b/lib/puppet/parser/functions/trocla_set.rb
index c3c9b49..06da5ae 100644
--- a/lib/puppet/parser/functions/trocla_set.rb
+++ b/lib/puppet/parser/functions/trocla_set.rb
@@ -38,21 +38,21 @@ trocla, for example via cli.
if args[0].is_a?(Array)
args = args[0]
end
-
+
key = args[0]
value = args[1]
raise(Puppet::ParseError, "You need to pass at least key & value as an argument!") if key.nil? || value.nil?
-
+
format = args[2] || 'plain'
return_format = args[3] || format
options = args[4] || {}
-
+
configfile = File.join(File.dirname(Puppet.settings[:config]), "troclarc.yaml")
-
+
raise(Puppet::ParseError, "Trocla config file #{configfile} not readable") unless File.exist?(configfile)
require 'trocla'
-
+
result = (trocla=Trocla.new(configfile)).set_password(key,format,value)
if format != return_format && (result = trocla.get_password(key,return_format)).nil?
raise(Puppet::ParseError, "Plaintext password is not present, but required to return password in format #{return_format}") if (return_format == 'plain') || trocla.get_password(key,'plain').nil?