Possible to include subdirectories of modules?

34 views
Skip to first unread message

Antonios Dimtsoudis

unread,
Feb 19, 2015, 8:36:01 AM2/19/15
to puppet...@googlegroups.com
Hello,


i want to include subdirectories of modules, for example something like:
cat modules/configuration/git/manifests/init.pp
class git {

   
if $::osfamily == 'redhat' {
       
package {
           
'git': ensure => present,
       
}
   
}
}

And then include git like:
cat manifests/site/git.pp
node git
.domain.tst {
    include
"configuration/git"
}


I want to have my modules more structured and subdirectories would be a good solution for me here..


Thanks,
Antonios.

David Bryant-Moore

unread,
Feb 19, 2015, 12:01:18 PM2/19/15
to puppet...@googlegroups.com
Hi Antonias.

The way you would implement the pattern you want is to use Puppet namespacing.

To explain this using your example code below, your directory structure would need to change to:

modules/configuration/manifests/git

And your include statement would change to:

include configuration::git

This method of referencing Puppet classes is really useful.  The rule to apply when 
namespacing classes in this manner is that the final element of every name space must
always resolve to a puppet class, represented as a .pp file of the same name within the module.

Consider:


modules/foo/manifests/bar.pp

Would be declared as: include foo::bar

Whereas:

modules/foo/manifests/bar/baz.pp

Would be declared as: include foo::bar::baz


HTH

David Bryant-Moore.
Reply all
Reply to author
Forward
0 new messages