Domanda

I'm using Puppet and I'm having a bunch of modules. These modules all use custom defined types. Pretty much all custom defined types are used by each module so it doesn't make sense to put these types into a certain module. It's a bit like util classes with static methods in Java.

I've organized related types into classes which are written into a .pp file each and put them into $manifestdir. In $manifestdir/site.pp there's an import statement for each of these .pp files.

Scheme (what's in a name?):

$manifestdir/site.pp
 imports $manifestdir/class1.pp
  contains class class1
   contains type definitions for custom_type1, custom_type2, custom_type3
 imports $manifestdir/class2.pp
  contains class class2
   contains type definitions for custom_type4, custom_type5, custom_type6
 imports $manifestdir/class3.pp
  contains class class3
   contains type definitions for custom_type7, custom_type8, custom_type9

From inside each module then I can use such a custom defined type by addressing class1::custom_type2 or class3::custom_type7...

Now I've read that it's best practices to generally avoid the import keyword (see http://docs.puppetlabs.com/puppet/2.7/reference/lang_import.html). So I wonder what would be the best way to organize the custom types that are not modules specific and are needed by pretty much every module.

Thanks for your help!

È stato utile?

Soluzione

Simply create a "common" or "utils" module with all the shared types. Just like pupptelab's stdlib

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top