Existem três maneiras.
- Jeff McCune tem uma ótima função em seu github que faz exatamente isso:
module Puppet::Parser::Functions
newfunction(:getconf, :type => :rvalue, :doc =>
2010-09-29
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.
END_HEREDOC
do |args|
if args.length != 1 then
raise Puppet::ParseError, ("ERROR: getconf() takes only one argument")
end
Puppet[args[0]]
end # do |args|
end # module
# EOF
Coloque isso em um arquivo chamado 'getconf.rb' na libdir do seu servidor de marionetes ( /var/puppet/lib/puppet/parser/functions/getconf.rb ) e acesse-o a partir de um manifesto como
# somemanifest.pp
$myvar = getconf("ssldir")
notify {"set ssldir to ${myvar}":}
2. No Puppet 2.6, é ainda mais fácil, pois a configuração das configurações é acessível como ${settings::somevar} , portanto, o manifesto é simplesmente:
# 26manifest.pp
$myvar = $settings::ssldir
notify {"set ssldir to $myvar":}
3. No boneco 0.25 você pode usar um modelo in-line:
# 25manifest.pp
$myvar = inline_template("<%= Puppet.settings[:ssldir] %>")
notify {"set ssldir to ${myvar}":}
Métodos 2 e 3 graças a este tópico sobre usuários de marionetes