Ask Your Question
0

Convert class entry in site.pp to module

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

bmurts gravatar image

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

Hello,

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 => [ '10.1.1.36', 
                   '10.1.1.37', ],
  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?

Thanks,

Brendan

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

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

binford2k gravatar image

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

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,

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

Your ntp.pp file would look like:

class site::ntp {
  class { 'ntp':
    server_list => [ '10.1.1.36', 
                     '10.1.1.37', ],
    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
3

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

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_list:
  - '10.1.1.36'
  - '10.1.1.37'
ntp::server_enabled: true
edit flag offensive delete link more

Comments

@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 -0500 )edit
1

You should use hiera. Start with the documentation here, http://docs.puppetlabs.com/hiera/1/, 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 -0500 )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

Stats

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

Seen: 379 times

Last updated: Dec 18 '12