Michael Siroskey
2013-Jan-06 19:24 UTC
[Puppet Users] Custom function and SERVER: wrong argument type Class (expected Module)
I have created a custom function that I''m trying to use in my manifest. When I use the function I get the following error message on my client. Error: Could not retrieve catalog from remote server: Error 400 on SERVER: wrong argument type Class (expected Module) at /etc/puppet/manifests/nodes.pp:18 on node fubar Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run I have tested my function on server with a simple manifest locally and the function works properly. The function I’ve created was to pad the contents of a variable with tabs so when the variable is used in a configuration it will have the proper alignments for readability. Below is my function, I’ve removed parameter checking to simplify the code for troubleshooting. module Puppet::Parser::Functions newfunction(:talign, :type => :rvalue, :doc => <<-EOS Pads a string with tabs for alignment purposes. *Examples:* taligh(‘abcd’,24,8) Will return: abcd\t\t EOS ) do |arguments| value = arguments[0] space = arguments[1] if arguments.size == 2 tabsize = 8 else tabsize = arguments[2] end size = space.to_i - value.length if size <= 0 result = value + "\t" else count = size / tabsize.to_i while count > 0 do value = value + "\t" count = count - 1 end result = value end return result end end Here is the code that I’ve added to my manifest for testing. $temp = talign(''abc'',24,8) notify{"${temp}":} Thanks, Michael -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/vSdin1p-ziwJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Jakov Sosic
2013-Jun-08 16:20 UTC
Re: [Puppet Users] Custom function and SERVER: wrong argument type Class (expected Module)
On 01/06/2013 08:24 PM, Michael Siroskey wrote:> I have created a custom function that I''m trying to use in my manifest. > When I use the function I get the following error message on my client.> $temp = talign(''abc'',24,8) > > notify{"${temp}":}Where did you put your function, in what filepath? And did you run your agent with --pluginsync option? -- Jakov Sosic www.srce.unizg.hr -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.