Question

I'm using Puppet 3.5.1 on Linux 6 machine.

I have a local module "A" that includes a sub-module "B". Such that sub-module "B" is located in "/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)

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

B is then not reference any were else. When I start up puppet master and the puppet agent, I get the following error on the agent:

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. If that's the solution, since this is a module inside another module, how do I refer to it?

Edit 1

I moved the sub module "B" into the main modules folder, from "/etc/puppet/modules/A/modules" to "/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
Was it helpful?

Solution

Having a modules/ subtree in a module is no valid structure as far as the autoloader is concerned. 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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top