The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com
https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:
fqdn_rand() causes can't convert String into Integer error
|Affected Puppet version:||2.7.1||Branch:|
Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com
This is occurring in version 2.7.1 and in the master branch. I’m running ruby 1.9.2p290 on Arch Linux.
The section of my manifest looks like this:
$rand_hour = fqdn_rand(23,5445) $rand_minute = fqdn_rand(59,954)
From puppetd, I get:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Integer at /etc/puppet/manifests/mymanifest.pp:4 on node example.com
From puppetmasterd, I get:
err: can't convert String into Integer at /etc/puppet/manifests/mymanifest.pp:4 on node example.com
I tried a number of things, like using only one argument to fqdn_rand() but it turns out my version of Ruby’s rand function doesn’t like string arguments and that fqdn_rand’s arguments are strings when they reach rand.
I’ve included a patch that got things working for me.
#1 Updated by Nan Liu over 4 years ago
- Status changed from Unreviewed to Accepted
- Target version set to 2.7.x
- Keywords set to Ruby 1.9.2
Confirmed Ruby 1.9.2 does not handle rand with string, and the patch seems sensible:
ruby-1.9.2-p136 :002 > rand(4) => 1 ruby-1.9.2-p136 :003 > rand('4') TypeError: can't convert String into Integer from (irb):3:in `rand' from (irb):3 from /Users/nan/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in `<main>' ruby-1.9.2-p136 :004 > rand('4'.to_i) => 1 ruby-1.9.2-p136 :005 >
#2 Updated by James Turnbull over 4 years ago
- Category set to functions
- Status changed from Accepted to Requires CLA to be signed
Hi Noah! Thanks for your patch. Could I please get you to sign a CLA (see the Contributor License Agreement link in the top menu) and have a quick look at our http://projects.puppetlabs.com/projects/puppet/wiki/Development_Development_Lifecycle link?