commit f817b725879f7eefe162458de38ba49b2375d4a2 Author: Andrew Tomaka Date: Thu Oct 24 09:55:09 2013 -0400 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eaa6e54 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ruby-version diff --git a/lib/puppet/parser/functions/random_password.rb b/lib/puppet/parser/functions/random_password.rb new file mode 100644 index 0000000..0d0794c --- /dev/null +++ b/lib/puppet/parser/functions/random_password.rb @@ -0,0 +1,18 @@ +require 'securerandom' + +module Puppet::Parser::Functions + newfunction(:random_password, :type => :rvalue) do |args| + length = args[0] - 1 + store = args[1] + + if(args.length != 2) + raise Puppet::ParsError, 'Usage: random_password(length, store)' + end + + password = SecureRandom.hex[0..length] + + File.open(store, 'w') { |f| f.write(password) } + + return password + end +end diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..3bda8fe --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1 @@ +class random_password {}