2

I'm trying to make my own function. I keep getting this message.

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Function 'brent_k' does not return a value at /etc/puppet/modules/munin/manifests/init.pp:17 on node XYZ.com

Here is my simple code

xyz.com:/etc/puppet/modules/munin/lib/puppet/parser/functions# cat brent_k.rb module Puppet::Parser::Functions newfunction(:brent_k, :type => :rvalue) do |args| val = 'ok' val end end 

And then in my manifest, I have

$a = brent_k() 

I tried return val too. How can I fix this?

2
  • 3
    You may wish to accept some previous questions to ensure you get a good response. Commented Oct 18, 2012 at 12:18
  • K I found the answer. It appears puppet does some caching. So first I added 'ignorecache = true' to puppet.conf. But then I found that thats for the client caching. I then found that if I keep restarted puppetmaster, then I my dev env, I can see my changes / test. Commented Oct 18, 2012 at 13:41

2 Answers 2

4

When you change any custom ruby code, such as a custom function, you must restart the Puppetmaster. If you are running puppet under passenger, this means restarting Apache. Otherwise, you'll get the old version.

In addition, there is a rather nasty bug that kicks in if you are hosting multiple environments in your puppetmaster with an identically named function in the other environment. In this case, you have no way to be sure which environment's function is used when you call the function name! It uses the same function namespace across all environments... (this is confirmed to happen in Puppet 2.7.22, not sure about 3.x)

0

As the documentation says:

The puppet master caches custom functions. If you edit an existing function (e.g. while you’re developing it), you’ll need to restart the puppet master before the new version can be used.

https://puppet.com/docs/puppet/latest/writing_custom_functions.html

Note about restarting Puppet master:

If you execute the following command to restart Puppet master:

$ service puppetmaster restart Restarting puppet master puppetmaster not configured to start, please edit /etc/default/puppetmaster to enable . 

You will notice that the service stops but doesn't start.

In that case, as Steve Shipway mentioned, you are probably running Puppet master under Passenger and you need to reload apache2 to actually restart Puppet master:

$ service apache2 reload 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.