0

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

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

# @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值的目标名称?是否有一个特殊的值,就好像我们在循环中运行它一样?

4

1 回答 1

1

是的!您可以像 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']}
      ]
    }
  }
}
于 2021-11-29T17:25:50.090 回答