[Puppet Users] Re: Custom function: where to put the file?

Mike
Thu, 05 Jun 2008 05:14:29 -0000

Hold on, I just discovered generate(). This seems to provide the
functionality I need -- specifically, calling an external script
(written in any language :) to inject an external value into a Puppet
variable.

And thus I get to delay solving the custom-function puzzle until
another day.

On Jun 4, 11:56 am, Mike <mike.t...@gmail.com>
wrote:
> Thanks, Luke. Actually I see the timeout behavior fairly frequently.
> It''s become a signal to me that my configuration is busted
somehow.
> Usually I''ll follow these steps to confirm the signal:
>
> 1. Kill the running puppet check.
> 2. service puppetmaster restart
> 3. Start the puppet check again, and immediately see an error on the
> client that I forgot a closing brace or something like that on the
> server.
>
> I have assumed this was a feature of Puppet, where clients will retry
> a few times to give the foolhardy sysadmin time to fix the bug he
> introduced while editing the live puppetmaster configuration.
>
> Anyway, in this case, I don''t think failure to return is the
problem.
> There are two reasons I think this:
>
> 1. The behavior is the same even if I remove the file_last_line.rb
> entirely from the filesystem.
>
> 2. I''ve tried both the file_last_line.rb and rand.rb sample
functions
> given in the tutorial, and both behave the same way. It seems very
> unlikely that rand.rb is looping or hanging.
>
> I''m afraid I know next to nothing about Ruby, so I don''t
know what to
> do with your test script. I tried pasting it into a file called
> test.rb and then executing "ruby test.rb" on the command line,
and it
> said "uninitialized constant Puppet (NameError)."
>
> I expect at least one reader''s answer at this point will be
"go away
> and come back when you''ve learned Ruby; you have no business
trying to
> write custom Puppet functions until you have done so." But
I''ll let
> someone else start that flamewar. :)
>
> On Jun 4, 11:30 am, Luke Kanies <l...@madstop.com> wrote:
>
> > On Jun 4, 2008, at 11:11 AM, Mike wrote:
>
> > > All I ever see in /var/log/messages on a client run is this:
>
> > > Jun  4 13:50:08 myhostname puppetmasterd[23529]:
> > > (Scope(Node[myhostname.mycompany.com]))  hello
> > > Jun  4 13:52:00 myhostname puppetd[23536]: Configuration
retrieval
> > > timed out
> > > Jun  4 13:52:01 myhostname puppetd[23536]: Not using cache on
failed
> > > catalog
>
> > This indicates to me that your server is finding the function and
it''s
> > never returning.
>
> > Try running your function separately.  For instance, here''s a
test
> > script I recently wrote for a demo function:
>
> > describe Puppet::Parser::Functions.function(:spectest) do
> >      it "should get added to the list of functions" do
> >          Puppet::Parser::Functions.function(:spectest).should_not
> > be_false
> >      end
>
> >      it "should be a statement" do
> >          Puppet::Parser::Functions.should_not be_rvalue(:spectest)
> >      end
>
> >      it "should create a function named
''spectest''" do
> >          Puppet::Parser::Scope.instance_methods.should
> > be_include("function_spectest")
> >      end
>
> >      describe "when being executed" do
> >          it "should send an error message with its
arguments" do
> >              Puppet.expects(:err).with("one two")
> >              Puppet::Parser::Scope.new.function_spectest(%w{one two})
> >          end
> >      end
> > end
>
> > --
> > Take the utmost trouble to find the right thing to say, and then say
> > it with the utmost levity. -- George Bernard Shaw
> > ---------------------------------------------------------------------
> > Luke Kanies |http://reductivelabs.com|http://madstop.com