That should work. However, a more puppetish way of doing it is using a 
template to generate ntp.conf. I'm guessing the only difference between 
your ntp.conf's is the server setting. Here's how you could do it with a 
template:

in site.pp specify ntp servers for each site, e.g.: 

case $site { 
  sj: { 
    $ntpServerList = [ 'ntp1.sj', 'ntp2.sj' ]
  }
  to: { 
    $ntpServerList = [ 'ntp1.to', 'ntp2.to' ]
  }
}

then make an ntp.conf.erb in the templates directory that contains this: 

<% ntpServerList.each do |ntpServer| -%>
server <%= ntpServer %>
<% end -%>

then in your manifest: 

file { "/etc/ntp.conf":
  content => template("ntp/ntp.conf.erb"),
}

This way you have only one file to edit to change site-specific setings.

In our environment we have a function in site.pp that determines $site 
based on fqdn. 

-Eric

On Tue, 15 Sep 2009, Mark Christian wrote:

> 
> Following the example in the CommonMisconceptions I've done away with
> the inherits "base_node" and have instead included the class base_node
> and can now successfully pass my $site variable.  However I can't seem
> to include the variable in the "source" parameter for "file" type.
> 
> For now I'm using this:
> 
> file { "/etc/ntp.conf":
>         owner   => root,
>         group   => root,
>         mode    => 0644,
>         source => $site ? {
>             "sj"    => "puppet:///ntp/SJ/ntp.conf",
>             "to"    => "puppet:///ntp/TO/ntp.conf",
>             "uk"    => "puppet:///ntp/UK/ntp.conf",
>             "pg"    => "puppet:///ntp/PG/ntp.conf",
>             default => "puppet:///ntp/ntp.conf",
>         },
>         notify  => Service[ntpd],
>         require => Package["ntp"],
>     }
> 
> I was just hoping I could use this instead:
> 
> source  => "puppet:///ntp/$site/ntp.conf"
> 
> 
> 
> On Sep 15, 12:45 pm, Silviu Paragina <sil...@paragina.ro> wrote:
> > I thinks you are in the case explained 
> > herehttp://reductivelabs.com/trac/puppet/wiki/CommonMisconceptions
> >
> > Silviu
> >
> > Mark Christian wrote:
> > > say I have a couple nodes:
> >
> > > node 'uk-host' inherits basenode {
> > >     $site = "UK"
> > > }
> > > node 'ap-host' inherits basenode {
> > >     $site = "AP"
> > > }
> >
> > > Is it possible to pass the $site variable to the file resource source
> > > parameter?:
> >
> > > class ntp {
> >
> > >     package { ntp: ensure => installed }
> >
> > >     file { "/etc/ntp.conf":
> > >         owner   => root,
> > >         group   => root,
> > >         mode    => 0644,
> > >         source  => "puppet:///ntp/$site/ntp.conf",  # $modulepath/ntp/
> > > files/{AP,UK}/ntp.conf
> > >         source  => "puppet:///ntp/ntp.conf",
> > >         notify  => Service[ntpd],
> > >         require => Package["ntp"],
> > >     }
> >
> > >     service { ntpd:
> > >         name    => "ntpd",
> > >         enable  => true,
> > >         hasstatus => true,
> > >         hasrestart => true,
> > >         ensure  => running,
> > >         require => Package["ntp"],
> > >     }
> > > }
> >
> > > The above does not appear to work.  Am I simply misguided and should I
> > > be trying something else?  Thank you.
> >
> > > Mark
> > 
> 
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to