title: get random password with puppet function
body: <p>I have a function that allow me to generate random password. My function is working well without a puppetmaster. When I tried with a master an error appear when I called the function :</p>
  
  <pre><code>Error 400 on SERVER: bad value for range
  </code></pre>
  
  <p>Here is my function:</p>
  
  <pre><code>module Puppet::Parser::Functions
    newfunction(:get_random_password, :type =&gt; :rvalue, :doc =&gt; &lt;&lt;-EOS
  Returns a random password.
      EOS
    ) do |args|
      raise(Puppet::ParseError, "get_random_password(): Wrong number of arguments " +
        "given (#{args.size} for 1)") if args.size != 1
      specials = ((33..33).to_a + (35..38).to_a + (40..47).to_a + (58..64).to_a + (91..93).to_a + (95..96).to_a + (123..125).to_a).pack('U*').chars.to_a
      numbers  = (0..9).to_a
      alphal = ('a'..'z').to_a
      alphau = ('A'..'Z').to_a
      length = args[0]
      CHARS = (alphal + specials + numbers + alphau)
      pwd = CHARS.sort_by { rand }.join[0...length]
      return pwd
    end
  end
  </code></pre>
  
  <p>The function is called in both case with <code>$pwd = get_random_password(10)</code>.</p>
  
  <p>When I specified the length directly in the function to 10 for example. The password is well generated in master mode.</p>
  
  <p>Have you any idea why I can't specify the length value?</p>