Hi Brian,

On Jan 5, 4:31 am, Brian Pitts <b...@uga.edu> wrote:
> I'm curious how people handle the following situation in their node
> definitions- you have a default configuration of a service that you want
> on all of your servers except for the servers that have a more specific
> configuration. For example, I want all of my servers to include the
> sendmail::satellite class, except for one server where I include the
> sendmail::relay class. I already had a node definition that was at the
> bottom of the inheritance hierarchy for all my nodes, so adding a test
> like the one below seemed like a straightforward way of accomplishing this.
>
> node basenode {
>   if tagged(sendmail::relay) {
>     crit("$hostname is a sendmail relay")
>   } else {
>     crit("$hostname is NOT a sendmail relay")
>     include sendmail::satellite
>   }
>
> }
>
> node foo inherits basenode {
>   include sendmail::relay
>
> }

I've tried to do what you're trying to do before and I found it quite
messy. Using the tagged() function for classes will work, but I still
ran into problems with Puppet and the order in which it's classes and
resources were declared. I got it working using stages, making sure
that all my classes that were dependent on if() clauses were in a
stage before the classes actually running the if() clauses. It was a
real pain. In the end I scrapped the whole idea and approached from a
different angle.

Running with your example, every server is a Sendmail satellite, so
it'll have some File["sendmail.mc"] resource. Since that is your base
standard, why not have a child class to override the behaviour of
satellite to have relay functionality like so (renamed the classes to
make the name space more sensible):

class sendmail {
  file { "/etc/mail/sendmail.mc":
    ensure => present,
    source => "foo",
  }
}

class sendmail::relay inherits sendmail {
  File["/etc/mail/sendmail.mc"] {
    source => "bar",
  }
}

node basenode {
  include sendmail
}

node relay inherits basenode {
  include sendmail::relay
}

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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