Puppet Function: get_password
- Defined in:
- lib/puppet/parser/functions/get_password.rb
- Function type:
- Ruby 3.x API
Overview
return a password from the users.xml generated by jriviere/windows_ad module.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet/parser/functions/get_password.rb', line 8 newfunction(:get_password, :type => :rvalue, :doc => <<-EOS return a password from the users.xml generated by jriviere/windows_ad module. EOS ) do |args| raise(Puppet::ParseError, "get_password(): Wrong number of arguments " + "given (#{args.size} for 2)") if args.size != 2 require 'rexml/document' if (File.size?(args[1]) != nil) file = File.new(args[1]) doc = REXML::Document.new file root = doc.root users = root.elements["users"] users.elements.map do | user | if (user.attributes['name'] == args[0]) if(user.attributes['password'].empty?) raise(Puppet::ParseError, "get_password(): Cant get the password from the xml file. You need to fill a password in xml or use the variable in your manifest.") else return user.attributes['password'] end end end raise(Puppet::ParseError, "get_password(): Cant get the password from the xml file. You need to fill a password in xml or use the variable in your manifest.") end end |