Implicit conversion of string to integer error with ec2_userdata

214 views
Skip to first unread message

mhoey

unread,
May 27, 2014, 3:26:51 PM5/27/14
to puppet...@googlegroups.com
I recently installed a puppet 3.4.3 puppetmaster. I am working on a project to convert all of our manifests over from 2.7 to 3.4.3. While trying to run a master/agent setup on the puppetmaster itself, I am getting the following error:

"Error: Could not retrieve catalog from remote server: Error 400 on SERVER: no implicit conversion of String into Integer."

The line in question is a  call to a custom function. The problem seems to go back to the "ec2_userdata" facter fact. If I alter the line "userdata.split" to just "userdata" in /usr/lib/ruby/vendor_ruby/facter/ec2.rb everything starts to work. What's interesting is that when I alter my function to not even use this variable (for debug purposes) it still throws the error. This leads me to believe that this fact is getting loaded no matter what and ultimately causing the problem.

I saw in the Facter 2.0.1 documentation that arrays are now accepted but puppet does not have them turned on by default. I set stringify_facts to false in both main and master sections of puppet.conf but the problem still persists.

Any help would be appreciated. Here is my environment:

puppet 3.4.3
facter 2.0.1
ubuntu 14.04
ruby 2.0.0 and ruby 1.9.1 with I believe all of the binaries (ruby, irb, gem, etc) pointing at 2.0. no rvm or rbenv

jcbollinger

unread,
May 29, 2014, 10:05:07 AM5/29/14
to puppet...@googlegroups.com


On Tuesday, May 27, 2014 2:26:51 PM UTC-5, mhoey wrote:
I recently installed a puppet 3.4.3 puppetmaster. I am working on a project to convert all of our manifests over from 2.7 to 3.4.3. While trying to run a master/agent setup on the puppetmaster itself, I am getting the following error:

"Error: Could not retrieve catalog from remote server: Error 400 on SERVER: no implicit conversion of String into Integer."

The line in question is a  call to a custom function. The problem seems to go back to the "ec2_userdata" facter fact. If I alter the line "userdata.split" to just "userdata" in /usr/lib/ruby/vendor_ruby/facter/ec2.rb everything starts to work. What's interesting is that when I alter my function to not even use this variable (for debug purposes) it still throws the error. This leads me to believe that this fact is getting loaded no matter what and ultimately causing the problem.



The custom function is probably the issue.  Puppet 2 accepts sloppier custom function definitions; somewhere in the Puppet 3 series puppet started enforcing the rules more rigorously (as I understand it, the rules themselves did not change).

Anyway, we really need to see some code to confirm that diagnosis or offer a different one.  The custom function (at least its first few lines), the section of the manifest where it is invoked, and the argument values being passed should be sufficient.

 
I saw in the Facter 2.0.1 documentation that arrays are now accepted but puppet does not have them turned on by default. I set stringify_facts to false in both main and master sections of puppet.conf but the problem still persists.



I'm sure that's not your issue.  Facter's default behavior is the traditional one, so if your code worked Puppet 2 / Facter 1 then it should not be necessary to enable the new structured facts support to make it work in Puppet 3 / Facter 2.


John

mhoey

unread,
Jul 9, 2014, 9:31:22 PM7/9/14
to puppet...@googlegroups.com
Here is the function. Some identifying characters were removed but I think overall it's fine. The library file (ops/vault) has a lot of proprietary stuff in it and let me just say it works perfectly fine so I really don't think that's the problem. The call in the puppet manifest looks like this: $monitoring_snmp_user = vault("global_snmp_user")

require 'ops/vault'
require 'json'

module Puppet::Parser::Functions
  newfunction(:vault, :type => :rvalue) do |args|
    auth = nil
    value = nil
    nv = nil
    tmp_json = lookupvar("ec2_userdata")
    user_data = JSON.parse(tmp_json)
    domain = user_data["tier_public_domain"]
    begin
      if args[0]
        nv = Vault.new(:tier_public_domain => domain)
        tmp = nv.get(args[0])
        if tmp.to_s != ""
          value = tmp
        end
      end
    rescue Exception => e
      value = ""
    end
    return value
  end
end
Reply all
Reply to author
Forward
0 new messages