summaryrefslogtreecommitdiff
path: root/modules/pass/lib/puppet/functions/pass.rb
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pass/lib/puppet/functions/pass.rb')
-rw-r--r--modules/pass/lib/puppet/functions/pass.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/pass/lib/puppet/functions/pass.rb b/modules/pass/lib/puppet/functions/pass.rb
new file mode 100644
index 0000000..176e7e9
--- /dev/null
+++ b/modules/pass/lib/puppet/functions/pass.rb
@@ -0,0 +1,21 @@
+# require 'open3'
+
+Puppet::Functions.create_function(:pass) do
+ dispatch :method do
+ param 'String', :path
+ optional_param 'String', :salt
+ end
+
+ def method(path, salt = path)
+ # Salt was an attempt to not regenerate the entry every run.
+ # This however failed, since the command is still run, and puppet
+ # doesn't diff betwen runs
+ # -salt #{salt}
+ #
+ # TODO fetch passwords in some slightly more portable way
+ `openssl passwd -apr1 $(sudo -Hu hugo pass #{path})`
+ # Open3.popen3("sudo -Hu hugo pass #{path}") do |stdin, stdout, stderr, thread|
+ # stdout.read.chomp
+ # end
+ end
+end