简体   繁体   English

引用模块内部模块的人偶

[英]Puppet referring to a module inside a module

I'm using Puppet 3.5.1 on Linux 6 machine. 我在Linux 6机器上使用Puppet 3.5.1。

I have a local module "A" that includes a sub-module "B". 我有一个包含子模块“ B”的本地模块“ A”。 Such that sub-module "B" is located in "/etc/puppet/modules/A/modules/B". 这样子模块“ B”位于“ / etc / puppet / modules / A / modules / B”中。

I refer to sub-module "B" in my module "A" classes: (/etc/puppet/modules/A/manifest/init.pp file) 我在模块“ A”类中引用子模块“ B”:(/ etc / puppet / modules / A / manifest / init.pp文件)

class A::one (
...
    class { 'B': 
        val1 => 'abc',
        val2 => 'abc',
    }
...
)

B is then not reference any were else. 然后,B不引用任何其他对象。 When I start up puppet master and the puppet agent, I get the following error on the agent: 当启动puppet master和puppet代理时,在代理上出现以下错误:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class B

What have I missed? 我错过了什么?

I saw some posts had the resolution as adding a 'include B' for the puppet agent node. 我看到一些帖子的解决方案是为人偶代理节点添加“ include B”。 If that's the solution, since this is a module inside another module, how do I refer to it? 如果是这样的解决方案,因为这是另一个模块中的一个模块,我该如何引用它?

Edit 1 编辑1

I moved the sub module "B" into the main modules folder, from "/etc/puppet/modules/A/modules" to "/etc/puppet/modules". 我将子模块“ B”从“ / etc / puppet / modules / A / modules”移动到“ / etc / puppet / modules”中。 It gave the the error: 它给出了错误:

Error: Duplicate declaration: Class[B] is already declared; cannot redeclare at /etc/puppet/modules/A/manifest/init.pp

Having a modules/ subtree in a module is no valid structure as far as the autoloader is concerned. 就自动装载器而言,在模块中具有modules/子树不是有效的结构。 There is no semantics for submodules. 子模块没有语义。

If you desperately want this particular case to work, you will have to add /etc/puppet/modules/A to your modulepath config setting. 如果您非常希望这种特殊情况能够正常工作,则必须将/etc/puppet/modules/Amodulepath配置设置中。

You may wish to ask a new question and describe what you are actually trying to solve, because it seems that your code architecture is a little unclean. 您可能希望提出一个新问题并描述您实际要解决的问题,因为您的代码体系结构似乎有点不干净。

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

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