Search code examples
puppet

How to include modules from a different directory in puppet


My module tree is like this

   - modules
     - socle1
       - stdlib
     - socle2
       - ntp

How do I include the stdlib module in my site.pp?

I have tried include socle1::stdlib and it is not working .

Should I modify the environment.conf for the directory environment?


Solution

  • If you want to arrange your modules in separate trees, then you may do so. You should then include each base path in your environment's modulepath, and refer to the modules by their regular names. Note in particular that altering the path to a module does not change its name or the names of any of the classes or types it defines -- the path influences only whether the autoloader can find them.

    I strongly advise against making subdirectories of the standard module directory, however. Instead, if you want to group modules in multiple directories then create parallel module directories for that purpose:

    - modules
    - socle1
      - stdlib
    - socle2
      - ntp
    

    Should I modify the environment.conf for the directory environment?

    In order to support any module directories beyond or instead of the default, yes, you should. The puppet documentation describes how to configure your environment's modulepath. But do consider following @MattSchuchard's advice and instead restricting yourself to the standard module directories.