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 => "domain.com",
searchpath => ['domain.com'],
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..
Try this:
For server you want to exclude
syslog::base
:and for all other servers:
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.
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.