And yes, I do understand that the custom function will always run on the puppet master. It's just that only the config for this particular host originally triggered the problem, so that's where I boiled it down to a simpler test case.
On Tue, Jul 24, 2012 at 1:17 PM, Andrew Parker <[email protected]> wrote: > What version of puppet are you using? Also, what do you get if you run it > with --trace? > > On Jul 24, 2012, at 11:06 AM, Matthew Probst wrote: > > > I'm having a difficult time with a custom function: > > > > module Puppet::Parser::Functions > > newfunction(:subpaths, :type => :rvalue) do |args| > > result = [] > > args.flatten.each do |path| > > temp_path = path > > begin > > result << temp_path > > temp_path = File.dirname(temp_path) > > end while (temp_path != "/" and temp_path != ".") > > end > > return result.uniq > > end > > end > > > > > > > > If I try calling this in a Puppet manifest: > > > > class testing { > > > > subpaths("/usr/local/bin") > > subpaths("/usr/local/bin", "/var/log/foo") > > subpaths(["/usr/local/bin","/var/log/foo"]) > > > > } > > > > > > and I get that to run on a host, with no other classes called, I get an > error > > > > Error 400 on SERVER: can't convert Array into String > > > > I tried changing my custom function to > > > > > > module Puppet::Parser::Functions > > newfunction(:subpaths, :type => :rvalue) do |args| > > return "" > > end > > end > > > > > > and it still does the same thing. > > > > > > I see in the bug tracker that several times in the past the ability to > pass in arrays has been broken through inadvertent changes, but I see no > recent discussion on whether you _should_ be able to pass arrays in; in > other words, it could be an intentional design, in which case I can just > try something else. > > > > However, when I browse the source code in > /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions, I don't see any magic > in the functions that accept arrays, except that many seem to use .flatten > on the args array passed in. > > > > I tried that in my initial attempt, and it seems that it fails before it > even gets to calling the custom function. > > > > I've tried looking in the mailing lists and searching the web, but most > mentions of this seem to be for older pre-2.x versions of Puppet. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Puppet Developers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected]. > > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
