Puppet 运行 个带有子模块的阶段

Puppet Run Stages with sub modules

我正在学习 Puppet 并学习了他们的 "Getting Started with Puppet" class 但它没有涵盖 运行 个阶段,并且他们关于 运行 个阶段的文档很薄。

我需要确保在 Puppet 做任何其他事情之前先发生两件事。 "Getting Started with Puppet" class 的导师建议我查看 运行 个阶段。

在我对 运行 阶段的调查中,我了解到 puppetlabs-stdlib class 设置了一些 "standard" 运行 阶段。其中之一是 "setup"。如下面的代码片段所示,我已经按照 https://puppet.com/docs/puppet/5.5/lang_run_stages.html 实现了 stage => 'setup'。但是,我从 Puppet 收到错误消息:

root@server:~# puppet agent -t
Info: Using configured environment 'dev_branch'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: 
Server Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find stage setup specified by 
Class[Vpn::Roles::Vpn::Client] (file: 

/etc/puppetlabs/code/environments/wal_prod1910_dev/modules/bh/manifests/roles/snaplocker.pp,行:5,列:3) 在节点服务器上 警告:不在失败的目录上使用缓存 错误:无法检索目录;跳过 运行

查看错误消息和 Puppet 文档,我在各种字符串值周围添加了引号,并将我的初始 -> 替换为正确的 =>,但我仍然遇到相同的错误。

class bh::roles::snaplocker()
{
  # stage => setup takes advantage of the setup run stage introduced by
  #  puppetlabs-stdlib which is pulled in by puppet-control-bh/Puppetfile
  class { 'vpn::roles::vpn::client': stage => 'setup' }

  class { 'bh::profiles::move_archives': stage => 'setup' }

  #...
}

仔细查看错误消息,我认为原因是 Puppetfile 在 class 中引入的 puppetlabs-stdlib id 调用了我正在处理的模块.我一直在故意避免尝试在我正在努力避免重复的 class 中加入 puppetlabs-stdlib。但显然我需要它...我正在处理的模块没有 Puppetfile 我需要以某种方式在我的子模块中包含 puppetlabs-stdlib 吗?如果是这样我应该怎么做?如果不是,我如何告诉我的子模块使用在父模块的 Puppetfile?

中声明的实例

通常,如果您有正确的 classes/resources 依赖项,则不需要任何 stage

来自"Run stages" documentation

CAUTION: Due to these limitations, use stages with the simplest of classes, and only when absolutely necessary. A valid use case is mass dependencies like package repositories.

在你的情况下,如果你真的想要阶段,你应该添加 include stdlib::stages1 或明确添加阶段,如 stage { 'setup': }