Puppet Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class

Puppet Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class

我正在尝试使用 github - https://github.com/ribeiroit/boh-puppet

上发布的说明通过 Puppet 部署一个名为 Bag-Of-Holding 的应用程序

我运行命令:sudo puppet apply /etc/puppet/manifests/site.pp 我收到以下错误:

Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class boh at /etc/puppet/manifests/site.pp:2:2 on node lab1-hp-elitebook-8570p

人偶似乎很难找到清单文件夹中已经存在的 class boh

这是我的目录树:

/etc/puppet
├── code
├── manifests
└── modules
    └── boh-puppet
        ├── manifests
        └── templates

我的 site.pp 文件位于 /etc/puppet/manifests 它看起来像这样:

node 'lab1-hp-elitebook-8570p' {
  class { 'boh':
    python_version   => 3,
    environment      => 'dev',
    language         => 'en',
    debug            => 'True',
    create_superuser => 'true',
    pkg_checksum     => '86b0164f7fd6c5e4aa43c8f056f08cea'
  }
}

并且 init.pp 文件具有 class {boh } 并且位于: /etc/puppet/modules/boh-puppet/manifests

有什么解决办法吗?

您没有正确调用模块名称。这应该有效:

node 'lab1-hp-elitebook-8570p' {
        class { 'boh-puppet':
        python_version => 3,
        environment => 'dev',
        language => 'en',
        debug => 'True',
        create_superuser => 'true',
        pkg_checksum => '86b0164f7fd6c5e4aa43c8f056f08cea'
        }
}

或 fqn 这个:

node 'lab1-hp-elitebook-8570p' {
        class { '::boh-puppet':
        python_version => 3,
        environment => 'dev',
        language => 'en',
        debug => 'True',
        create_superuser => 'true',
        pkg_checksum => '86b0164f7fd6c5e4aa43c8f056f08cea'
        }
}

Puppet 在自动加载时需要某些名称空间限制和模块目录结构约定以及 class 名称。在这种情况下,通过将 boh-puppet 的模块目录重命名为简单的 boh,可以最简单干净地解决您的问题以遵循正常约定。这将解决您的问题。

有关更多信息,请参阅此处的文档:https://puppet.com/docs/puppet/4.10/lang_namespaces.html

由于您使用 puppet apply 和绝对路径,您还需要通过将命令修改为 sudo puppet apply --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp.

来提供模块的路径