Initial commit
This commit is contained in:
commit
f817b72587
3 changed files with 20 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.ruby-version
|
18
lib/puppet/parser/functions/random_password.rb
Normal file
18
lib/puppet/parser/functions/random_password.rb
Normal file
|
@ -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
|
1
manifests/init.pp
Normal file
1
manifests/init.pp
Normal file
|
@ -0,0 +1 @@
|
|||
class random_password {}
|
Loading…
Reference in a new issue