Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to access Puppet master configuration variables (like confdir, masterport, etc) from within a Puppet manifest?

share|improve this question
up vote 5 down vote accepted

There are three ways.

  1. Jeff McCune has a nice function on his github that does exactly this:
    module Puppet::Parser::Functions
      newfunction(:getconf, :type => :rvalue, :doc => 

    The getconf function takes a single argument, the name of a
    configuration setting and returns the value of that setting.

    It is similar to the --configprint command line argument to
    return configuration settings except it exposes this information
    to the language.
      do |args|
        if args.length != 1 then
          raise Puppet::ParseError, ("ERROR: getconf() takes only one argument")
      end # do |args|
    end # module
    # EOF

Put this in a file called 'getconf.rb' in your puppet server's libdir (/var/puppet/lib/puppet/parser/functions/getconf.rb) and access it from a manifest like

# somemanifest.pp
$myvar = getconf("ssldir")
notify {"set ssldir to ${myvar}":}

2. In Puppet 2.6 it's even easier as the whole settings setup is accessible as ${settings::somevar}, so the manifest is simply:

# 26manifest.pp
$myvar = $settings::ssldir
notify {"set ssldir to $myvar":}

3. In puppet 0.25 you can use an inline template:

# 25manifest.pp 
$myvar = inline_template("<%= Puppet.settings[:ssldir] %>")
notify {"set ssldir to ${myvar}":}

Methods 2 and 3 thanks to this thread on puppet-users

share|improve this answer

not as far as i know. what are you trying to do?

share|improve this answer
I do a lot of custom plugins, so instead of using environments I am running two separate daemons for Production and Testing. Some of my plugins (including my external nodes script) need to reference external config files whose locations change based on the daemon I'm in. I'd like to be able to set a variable in my puppet.conf and then reference it from my manifests instead of having to change the locations on every pull/merge from testing to production. – sh-beta Jan 28 '10 at 15:22
i see now. have you thought of running production and test daemons in chroot'ed environment, so you can use same paths in both environments? lets say /etc/test/puppet and /etc/prod/puppet, and when you start youd chroot first to either /etc/test or /etc/prod ? just like bind does? and then within that env paths are the same – rytis Jan 28 '10 at 20:42
That would work for this particular example but other things like the puppet-client module, which requires the puppetmaster name and port number, are still problematic. – sh-beta Feb 3 '10 at 18:11
Marking this as my answer since it doesn't appear to be possible. – sh-beta Mar 15 '10 at 14:24
Times change. No longer the answer. – sh-beta Apr 15 '11 at 22:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.