On Sep 23, 6:40 am, Chris <[email protected]> wrote: > 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. > > I currently am using LDAP external nodes, and I see two ways of > assigning classes to hosts > > 1. use the puppetClass attribute, and assign classes directly. However, > extlookup cannot query ldap, so I could not query this data within my > manifests
extlookup() does not query LDAP *out-of-the-box*, but you can hook up alternative back-ends to it. I think an LDAP back-end is available (though not in the base distribution), but even if not then it shouldn't be that hard to create one. By the same token, it shouldn't be unreasonably difficult to write your own custom function that performs LDAP variable lookups for you. [...] > I would like to keep the classes self contained, so that the bacula > client template file or class has a generic include mechanism, and the > apache class would define all the required backup directories. Any > ideas around that? Forgive me, but I'm missing the distinction you are trying to draw. Why is it more self-contained for all your service classes to expose variables intended only for consumption by your bacula client template than it is for your bacula template or class to contain code for every potential service? In the latter case everything would at least be centralized, and you would not need to place additional requirements on every single other service class. Nevertheless, if you insist on proceeding in the direction you describe, then you may find it convenient to use the 'scope' object exposed to your template to examine all in-scope variables. For each service the node has, declare a top-level variable having a recognizable name pattern and whatever value you want. Your template should easily be able to sift these out of the overall set of in-scope variables and do whatever you want with them. John -- 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.
