Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have created a base class for all the servers in puppet,

class centos_base {
        include chkconfig
        include hosts
        include inittab
        include nscd
        include nsswitch
        include ntp
        include puppet
        include syslog::base
        include ssh
#        include curp
        include security
        include sysctl
        include sudo
        include users
        include vim
        include yum
        include rpmforge
#       include vmware-tools

        import 'resolver'

        resolv_conf { default_resolver:
                domainname  => "",
                searchpath  => [''],
                nameservers => ['x.x.x.y', 'x.x.y.y' ],

        import 'nrpe'

        nrpe_conf { nrpe:
                                listen_address => $ipaddress,
                                nagios_address => 'xx.xx.xx.yy',

and on nodes.pp, i include this class for all servers, for one of the server,i want to include this class but exclude syslog::base.

any idea how this can be done..

share|improve this question
up vote 3 down vote accepted

Try this:

class centos_base {
    define includer($exclude=false) {
        if !$exclude {
            include $name

    includer{ ["chkconfig", "hosts", ...: }

    class no_syslog_base inherits centos_base {
        Includer["syslog::base"] { exclude => true }

For server you want to exclude syslog::base:

node 'special' {
    include centos_base::no_syslog_base

and for all other servers:

node 'normal' {
    include centos_base
share|improve this answer

Turn it into a define and specify a parameter that describes the reason why you want to exclude that class -- it might be because it's a VM, or a staging environment, or whatever.

share|improve this answer
any example on how to do this??? – krisdigitx Sep 29 '11 at 10:08

The way I like to solve this sort of problem is by making the class smart enough to know where it should not be run. For example, I have a class that should be run only on machines that have an SSD; rather than doing a lot of up-front work to define which machines those were and build conditional classes, or create a specific set of classes to include for each named host, I wrote a custom Facter fact to determine whether the machine had an SSD installed (inspecting /sys/block/sd*/queue/rotational). Then I wrote the class as "if ($has_ssd) {...". That way, I can include it on any machine, and it will only run if it's supposed to run.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.