Можно ли получить доступ к переменным конфигурации мастера Puppet (например, confdir, masterport и т. Д.) Из манифеста Puppet?
Есть три пути.
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
Поместите это в файл с именем getconf.rb в libdir вашего марионеточного сервера (/var/puppet/lib/puppet/parser/functions/getconf.rb
) и получить к нему доступ из манифеста, например
# somemanifest.pp
$myvar = getconf("ssldir")
notify {"set ssldir to ${myvar}":}
2. В Puppet 2.6 это еще проще, поскольку все настройки доступны как ${settings::somevar}
, поэтому манифест выглядит просто:
# 26manifest.pp
$myvar = $settings::ssldir
notify {"set ssldir to $myvar":}
3. В марионетке 0.25 вы можете использовать встроенный шаблон:
# 25manifest.pp
$myvar = inline_template("<%= Puppet.settings[:ssldir] %>")
notify {"set ssldir to ${myvar}":}
Методы 2 и 3 благодаря эта ветка на марионеточных пользователях
не насколько я знаю. Что ты пытаешься сделать?