'defined' might be what you are after ... something like:
class foo {
}
class { "foo":
}
if defined(Class["foo"]) {
notice("foo is defined")
} else {
notice("foo is not defined")
}
When you comment out the class { "foo": } then the expression results
in a negative.
ken.
On Thu, Jul 7, 2011 at 5:26 PM, Keith Minkler <[email protected]> wrote:
> In a bunch of my templates and manifests, I need to have logic which
> depends on whether or not a particular (other) puppet class is going
> to be installed on the machine.
>
> For example, for setting up the proper nagios monitors, you'd want to
> say something like "if this machine has the apache class, then
> configure apache monitoring" It's not feasible I think to put this
> logic in the "apache" class, since you'd have to have a way to build
> up the nagios config file from parts contained in many classes which
> sometimes are installed together.
>
> Is there a function I can call, or could you provide some advice on
> how to approach writing such a function, which will tell me that the
> machine the catalog is being compiled for also has a particular class
> as part of the catalog?
>
> Currently, I'm stuck writing templates and manifests which have a lot
> of "if the hostname matches this regex, or if the fqdn matches this
> regex..." since classes are applied by fqdn ultimately, however, this
> is growing unmanageable as we're moving to a more dynamic system of
> creating machines and assigning more arbitrary names to machines using
> an external nodes store...
>
> Without this feature, we're still stuck in many cases having to commit
> changes to the puppet repository when we make machines and can't make
> the jump to being fully automated machine creation with arbitrary host
> names. Additionally, IMO, it makes it very difficult to understand
> many manifests and templates with all the special casing for machine
> names, instead of asking about installed classes.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.