Ask Your Question

Convert class entry in site.pp to module

asked 2012-12-18 10:07:50 -0600

bmurts gravatar image

updated 2012-12-18 10:08:11 -0600


I'm trying to keep my site.pp file clean and orderly. I've installed saz's ntp module from the Forge and I think the only way I've found to implement it is by adding the following snippet to site.pp:

class { 'ntp':
  server_list => [ '', 
                   '', ],
  server_enabled => true,

Ideally, I'd like to bring that code into a module and simply do an include ntp with my above lines. What is the recommended way of doing this?



edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2012-12-18 14:07:28 -0600

binford2k gravatar image

updated 2012-12-18 14:12:15 -0600

The simplest (though not best) way, without adding extra configuration layers, is to simply make a site wrapper module that includes these custom configured items like this. For example,

├── manifests
│   ├── init.pp
│   └── ntp.pp
└── tests
    ├── init.pp
    └── ntp.pp

Your ntp.pp file would look like:

class site::ntp {
  class { 'ntp':
    server_list => [ '', 
                     '', ],
    server_enabled => true,

Now at this point you can simply classify the node with site::ntp. You can add wrappers for any other classes you need inside this module.

Do keep in mind that hiera is the way forward, and ... (more)

edit flag offensive delete link more

answered 2012-12-18 10:23:28 -0600

ashp gravatar image

The best way to handle this, assuming you are running Puppet 3.0, is to use Hiera to provide this data. In Puppet 3 things changed so that Hiera attempts to look up all class parameters automatically. To achieve your aim in hiera you could have a common.yaml with:

  - ''
  - ''
ntp::server_enabled: true
edit flag offensive delete link more


@ashp, running PE 2.7. I have not messed with Hiera yet in my testbed.. Is there abitger alternative?

bmurts gravatar imagebmurts ( 2012-12-18 13:50:40 -0600 )edit

You should use hiera. Start with the documentation here,, though you can skip the installation steps since it's installed by default on on ...(more)

binford2k gravatar imagebinford2k ( 2012-12-18 14:15:03 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-12-18 10:07:50 -0600

Seen: 430 times

Last updated: Dec 18 '12