On Wed, Jun 17, 2009 at 8:47 AM, Don<d...@blacksun.org> wrote: > >> My own ntp module[1] only knows two kinds of ntp hosts: servers and >> clients. The former connect to each other and external sources, while >> the latter only connect to the local servers. The distinction is easily >> done: those nodes which have set $ntp_servers are those which connect to >> these external servers and thus _are_ servers. All others are clients. > I did this too initially- but I consider NTP an "enterprise" service > and was > going to put it in /services/ but then I would end up with two NTP > modules- > one for NTP servers in /services and one for NTP clients. That seems > really > hackish. >
> I understand how this would work for a service like ssh- but what > about in the case of something > like NTP? In that case I would have: > > class ntp { > file { "/etc/ntp.conf": > source => "puppet:///ntp/ntpclient.conf", > require => Package["ntp"] > } > } > > class s_ntp { # in /services > file { "/etc/ntp.conf": > source => "puppet:///s_ntp/ntpserver.conf", > require => Package["ntp"] > } > } > > node basenode { > include ntp > } > > node xyz inherits basenode { > } > > Now if I do this for my NTP master: > > node ntpmaster inherits basenode { > include s_ntp > } > > I'm going to have two NTP files. Is there a way to excude the earlier > definition of NTP so I'm not trying to have it update the same file > twice? > > Is there a more sensible way of doing this that I'm not thinking of? > > Should I just avoid /services because I clearly don't understand what > it's > for? > This were template files com in really handy. Instead of having two ntp .conf files you use one ntp_conf.erb that has a case switch. When $ntp_server is set to true then you get one config file out of the template, if it is false or not set you get a second. the template file could look something like this: # NTP file manged by Puppet, any local edits will be lost # <% if ntp_server == true -%> ~ insert server configuration ~ <% end -%> ~ insert the client configuration~ # # EOF This will make an ntp.conf file that always has the same client information, for connecting to local ntp servers. Only files that are defined as being $ntp_server == true will get the server configuration information. Now your ntp class might look like this: class ntp { file { "/etc/ntp.conf": source => template("ntp/ntp_conf.erb"), require => Package["ntp"], } } And your node definitions like this: ( the change from inherit to include is caused by variable scoping) node basenode { include ntp } node xyz inherits basenode { } NTP master: node ntpmaster{ $ntp_server=true include basenode } Evan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---