使用应用块内的当前目标



我想知道是否可以在Bolt中的apply块中检索当前目标。

例如,我想使用以下计划在远程机器上引导木偶:

# @summary This plan installs Puppet and configure it to use emypuppet-master.local as Puppet master
# @param targets The targets to run on.
plan puppet_bootstrapping::install_and_configure (
TargetSpec $targets,
) {
out::message("Installing Puppet")
apply_prep($targets)
apply($targets, '_description' => 'Configuring Puppet') {
class {'::puppet_agent':
manage_repo => false,
config => [
{section => main, setting => runinterval, value => '30m'},
{section => main, setting => environment, ensure => absent},
{section => main, setting => servername, value => 'mypuppet-master.local'},
{section => main, setting => certname, value => ????????}
]
}
}
}

如何获取certname值的目标名称?有没有一个特殊的值,就好像我们在循环中运行它一样?

是的!您可以访问应用程序块中的事实,就像Puppet代码一样,包括可信事实:

# @summary This plan installs Puppet and configure it to use mypuppet-master.local as Puppet master
# @param targets The targets to run on.
plan puppet_bootstrapping::install_and_configure (
TargetSpec $targets,
) {
out::message("Installing Puppet")
apply_prep($targets)
apply($targets, '_description' => 'Configuring Puppet') {
class {'::puppet_agent':
manage_repo => false,
config => [
{section => main, setting => runinterval, value => '30m'},
{section => main, setting => environment, ensure => absent},
{section => main, setting => servername, value => 'mypuppet-master.local'},
{section => main, setting => certname, value => $trusted['certname']}
]
}
}
}

最新更新