Question

I'm using puppet to auto-provision servers on a cloud infrastructure. I split my manifests in several .pp's.

I have the following error:

Could not find dependency Mehc_module::Filestructure::File[/someFolder/someSubFolder]

The relevant parts:

filestructure.pp

class mehc_module::filestructure{
file {
        "/someFolder/someSubFolder":
           ensure  => link,
           owner   => $mehc_module::users::WEBLOGIC_UID,
           group   => $mehc_module::users::WEBLOGIC_GID,
           target  => "/opt/user_projects",
           require => UserDefinedFolder["/someFolder"];
    }

packages.pp

class mehc_module::packages{
    require mehc_module::filestructure

    ...
    mehc_repo::package { "${common11rpm}" :
    ensure => present,
    require => [
        Mehc_module::Filestructure::File["/someFolder/someSubFolder"]
    ];
    }
}

Why does it give me the error?

Was it helpful?

Solution

Your resource reference is not structured correctly. You just want to

require => File["/someFolder/someSubFolder"]

Resource references do not take the manifest context into account. Even if they would, the "full path" to the resource would be Class[mehc_module::filestructure]/File["/someFolder/someSubFolder"]. But that will not work either.

The plain File["/someFolder/someSubFolder"] reference is sufficient because each resource can only be defined once in the whole of your manifest (including all modules).

Note that it is often a better practice to just

require => Class["mehc_module::filestructure"]

as this will imply the above relationship ("depend on all resources declared in the class") without tying the implementation of mehc_module::packages to implementation details of mehc_module::filestructure.

A notable exception from this rule is cases where the class you depend upon declares a large number of resources, thus leading to graph complexity (with performance implications), and a heightened danger of dependency cycles. The Anchor Pattern helps with those cases.

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