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?



Hostnames are edited.  Otherwise cut and pasted.

On the puppet master and on the client:



[root@puppet-client ~]# puppet --version
2.7.18

[root@puppet-master ~]# puppet --version
2.7.18



Here's a run with --trace:



[root@puppet-client ~]# puppet agent --test --noop --trace
notice: Ignoring --listen on onetime run
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:56:in `deserialize'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:120:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:196:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:240:in
`retrieve_new_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:490:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:489:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:239:in
`retrieve_new_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:86:in `retrieve_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:112:in
`retrieve_and_apply_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:152:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:21:in `lock'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/1.8/sync.rb:229:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:95:in `with_client'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:41:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:172:in `call'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:172:in `controlled_run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:39:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:337:in `onetime'
/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:311:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:416:in `hook'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:407:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:69:in `execute'
/usr/bin/puppet:4
err: Could not retrieve catalog from remote server: Error 400 on SERVER:
can't convert Array into String at
/etc/puppet/environments/development/modules/testing/manifests/init.pp:7 on
node puppet-client
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run




This was run from the client.  The following is in effect for this client
right now:



nodes.pp:



node ' somebodys-server-at-somewhere ' {
include testing
}



modules/testing/manifests/init.pp:



# modules/testing/manifests/init.pp:
#
class testing {
 $foo = subpaths("/usr/local/bin")
 $bar = subpaths("/usr/local/bin", "/var/log/foo")
$baz = subpaths(["/usr/local/bin","/var/log/foo"])
 }



init.pp:7 is the third line which tries to assign to $baz.



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.

Reply via email to