How to set default values for downloaded modules?

29 views
Skip to first unread message

Sandra Schlichting

unread,
Aug 24, 2012, 11:32:31 AM8/24/12
to puppet...@googlegroups.com
Dear readers,

I would like to use the saz-ntp module from

When installed the class is called "ntp".

Ideally would I like each node to look like

node testsrv { include ntp }


Problem

I don't want to modify the downloaded module, but I would like to be able to specify my own ntp servers

class { 'ntp': server_list => [ 'yourLocalServer1', 'yourLocalServer2', ] }


Question

Is it possible to override the ntp class name, so I can create an ntp class with contains my ntp server names?

Or is it possible to create an myconfig::ntp so the node would just become?:

node testsrv { include myconfig::ntp }


Hugs,
Sandra

Ryan Coleman

unread,
Aug 24, 2012, 1:07:21 PM8/24/12
to puppet...@googlegroups.com
Hi Sanda,

On Fri, Aug 24, 2012 at 8:32 AM, Sandra Schlichting
<littles...@gmail.com> wrote:

> Is it possible to override the ntp class name, so I can create an ntp class
> with contains my ntp server names?

The author built his ntp module with parameterized classes [1] so that
you could modify its behavior and data without touching the Puppet
manifests at all. If you'd like to create an ntp class with your own
ntp server names, you declare the class [2] exactly like you
suggested.

class { 'ntp':
server_list => [ 'server1', 'server2', 'etc' ],
}

This is equivalent to writing include ntp but without just accepting
the default behavior and data.

> Hugs,
> Sandra
>

Hugs back!

--Ryan

[1] http://docs.puppetlabs.com/learning/modules2.html
[2] http://docs.puppetlabs.com/puppet/2.7/reference/lang_classes.html#declaring-a-class-like-a-resource

Sandra Schlichting

unread,
Aug 24, 2012, 2:13:37 PM8/24/12
to puppet...@googlegroups.com
Hi Ryan,

[snip]

This is equivalent to writing include ntp but without just accepting
the default behavior and data.

Yes, the following works
 
node testsrv {
class { 'ntp': 
  server_list => [ 'server1', 'server2', 'etc' ], 
}

but I would really like to have this instead

node testsrv { include ntp }
or
node testsrv { include myconfig::ntp }

Is that possible, or are we talking about different things? =)

Hugs,
Sandra

Calvin Walton

unread,
Aug 24, 2012, 3:26:13 PM8/24/12
to puppet...@googlegroups.com
On Fri, 2012-08-24 at 11:13 -0700, Sandra Schlichting wrote:
> Hi Ryan,
>
> [snip]
>
> This is equivalent to writing include ntp but without just accepting
> > the default behavior and data.
> >
>
> Yes, the following works
>
> node testsrv {
> class { 'ntp':
> server_list => [ 'server1', 'server2', 'etc' ],
> }
> }
>
> but I would really like to have this instead
>
> node testsrv { include ntp }
> or
> node testsrv { include myconfig::ntp }

using something like 'myconfig::ntp' (or any different name,
'ntp_local', etc.) would work fine. This would look like

class myconfig::ntp {
class { 'ntp':
server_list => [ 'a.example.com', 'b.example.com' ]
}
}

note testsrv {
include myconfig::ntp
}

--
Calvin Walton <calvin...@kepstin.ca>

Sandra Schlichting

unread,
Aug 24, 2012, 4:13:00 PM8/24/12
to puppet...@googlegroups.com
using something like 'myconfig::ntp' (or any different name,
'ntp_local', etc.) would work fine. This would look like

class myconfig::ntp {
        class { 'ntp':
                server_list => [ 'a.example.com', 'b.example.com' ]
        }
}

note testsrv {
        include myconfig::ntp
}

Awesome! Thanks a lot =)


 
Reply all
Reply to author
Forward
0 new messages