On Thu, 2011-09-22 at 13:26 -0700, jcbollinger wrote:
> >
> > I would like the backup_include to automatically include /var/www if
> > the host is an apache server (for example), and I would like those
> > directories to be defined in the apache class (not the bacula class)
> >
> > Any clever ways of achieving this?
>
>
> There are no particularly good ways to achieve that if you restrict
> yourself to Puppet DSL. Generally speaking, you never want your
> manifests to inquire about the node's target state -- they should
> dictate instead. Anyway, all the approaches I know that inquire about
> what other classes are declared for a given node suffer from order-
> dependence issues, so at best, using them makes your manifests
> brittle.
>
> Without going too far outside Puppet DSL, you can achieve your goal by
> externalizing some or all of your data. Then, instead of asking
> whether a particular class _has been_ assigned to the node, you can
> use extlookup(), hiera, or similar to ask whether that class _is
> supposed to be_ assigned, whether it already has been or not. For
> best results, use the same data to drive the actual choice of whether
> to assign the class.
>
> If you go that far, however, then you're already most of the way to a
> data-driven external node classifier. You might find it useful to go
> the rest of the way, thereby moving the logic out of your manifests
> altogether.
>
Currently my nodes are stored in ldap
I could either specify classes by including the ldap attribute
puppetClass directly, or setting a custom variable ($is_bacula_director
or $is_nagios_client), and include the class generic_server on all
nodes, which would look something like:
class generic_server {
if $is_bacula_client == 1 {
include bacula::client
}
...
}
afaik, extlookup can't query against ldap, but if I use the $is_*
variables, I could add a lot of
if (is_apache_server == 1) {
<add_backup_dir /var/www>
}
if (is_dns_server == 1) {
<add_backup_dir /var/named>
}
(pseudo)code to the bacula::client template
Is that along the lines of what you meant?
I would prefer to keep my classes self-contained, which means I would
rather have a generic include mechanism in the bacula template/client
class, and specify all needed directories in the relevant dns/apache
classes. Any thoughts on that?
--
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.