Puppet Parameterized Modules

 The obvious problem with this approach is that this class is an implementation detail of the module and as such should not be exposed outside of the module, i.e., we had to supply the parameter using Hiera as my_parameters::my_class::greeting: Hello.

Here we will rather parameterize the module and use that parameter in the class. Let us first create a parametrized module by creating a my_parameters_refactor module with the classes my_class and the usual main (my_parameters_refactor) class.

We update modules/my_parameters_refactor/manifests/my_class.pp:

# @summary A class using a parameterized module


# A class using a parameterized module


# @example

#   include my_parameters_refactor::my_class

class my_parameters_refactor::my_class {

  file { '/tmp/my_parameters_refactor':

    ensure  => 'present',

    content => $my_parameters_refactor::greeting,

    path    => '/tmp/my_parameters_refactor',



Notice that the class itself is not parameterized; rather it refers to a variable in the module itself 

We update-modules/my_parameters_refactor/manifests/init.pp:

# @summary A parameterized module


# A parameterized module


# @example

#   include my_parameters_refactor

class my_parameters_refactor( String $greeting ) {

  include my_parameters_refactor::my_class


As usual, we include the module in manifests/site.pp.

Finally, we supply the data for the module’s parameter in data/common.yaml


my_parameters::my_class::greeting: Hello

my_parameters_refactor::greeting: Hello

Github repo for:https://github.com/zippyopstraining/puppetarameterizedmodules

Relevant Blogs:

Puppet Hierarchy 

Puppet loops 

Puppet schedule  

Install docker on windows

Recent Comments

No comments

Leave a Comment