简体   繁体   English

Puppet评估错误:评估资源语句时出错,无法找到声明的类

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

I'm trying to deploy an application called Bag-Of-Holding via Puppet using the instruction as posted on github - https://github.com/ribeiroit/boh-puppet 我正在尝试使用github上发布的指令部署一个名为Bag-Of-Holding的应用程序 - https://github.com/ribeiroit/boh-puppet

I run the command: sudo puppet apply /etc/puppet/manifests/site.pp and I get the error below: 我运行命令: 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 错误:评估错误:评估资源声明时出错,无法在节点lab1-hp-elitebook-8570p上的/etc/puppet/manifests/site.pp:2:2找到声明的类boh

It appears the puppet is having hard time finding the class boh which is already in the manifest folder 似乎木偶很难找到已经在清单文件夹中的类boh

This is my directory tree: 这是我的目录树:

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

my site.pp file is located in /etc/puppet/manifests and it looks like this: 我的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'
  }
}

And init.pp file has the class {boh } and that's located at: /etc/puppet/modules/boh-puppet/manifests 并且init.pp文件具有class {boh }并且位于: /etc/puppet/modules/boh-puppet/manifests

Any ideas how to fix this? 任何想法如何解决这一问题?

Puppet requires certain namespace restrictions and conventions with module directory structure and class names when autoloading. 在自动加载时,Puppet需要某些名称空间限制和约定以及模块目录结构和类名。 In this case, your problem can be solved most simply and cleanly to follow normal conventions by renaming your module directory of boh-puppet to simply boh . 在这种情况下,你的问题可以简单地大部分解决,干净地通过重命名你的模块目录按照通常惯例boh-puppet简单地boh That will fix your issue. 这将解决您的问题。

Consult the documentation here for more information: https://puppet.com/docs/puppet/4.10/lang_namespaces.html 有关更多信息,请参阅此处的文档: https//puppet.com/docs/puppet/4.10/lang_namespaces.html

Since you are using puppet apply with absolute paths, you will also need to supply the path to your modules by modifying the command to: sudo puppet apply --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp . 由于您正在使用具有绝对路径的puppet apply ,您还需要通过将命令修改为以下命令来提供模块的路径: sudo puppet apply --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp

You are not calling the module name properly. 您没有正确调用模块名称。 This should work: 这应该工作:

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

or the fqn this: 或者fqn:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM