Hi Alexander, See my inline comments, should help you with your dependency issues. I CC'd the puppet-users list so others can benefit from the clarification and comment on the approach.
Cheers, Teyo On Fri, Jan 23, 2009 at 12:16 PM, Andrew Shafer <and...@reductivelabs.com>wrote: > > Any way to do what Alexander wants to? > > > ---------- Forwarded message ---------- > From: Alexander Pankratov <apankra...@iponweb.net> > Date: Fri, Jan 23, 2009 at 8:59 AM > Subject: Puppet classes dependencies question > To: and...@reductivelabs.com > > > Hi. > > Andrew, my name is Alexander Pankratov, I'm working for AppNexus and have a > question about class dependencies. > > I've searched puppet docs and google group, but didn't find appropriate > solution. I can perfectly define dependencies within resources, but I'd like > to know if there is any way to do this on higher level. > > The problem I'm trying to solve is like this: > > - I've created several modules, let's say 2: yum and physical-server. > - in yum module I configure yum repositories > - in physical-server module classes I configure the box and use plenty > (~200) of package { provider => yum } resources. > > Then, I include both classes in site.pp like > > class server-type-b { > include yum > include physical-server > } > > I want to be sure that before packages in physical-server are being > installed - yum repo is configured. > > Ofc, I can do this on per-resource basis. I.e. in each package {} in > physical-server explicitly require yum class like: > > require => Class ["yum"] > > There is currently no mechanism for setting metaparameters is on with in a > class. They can only be set inside a resource, but there are a couple of > other ways to express this dependency without setting the require => > Class["foo"] in the resource. > Resource Defaults approach: Set a meta-parameter for all packages inside of the physical-server class class physical-server { Package { require => Class["yum"] } # # All package resource in the class physical-server require yum. This can be overidden on a per-resource basis within the class or subclass. # } Relationship inversion: Set the meta-parameter within the file resource that sets up the metaparameter. class yum { file {'/etc/yum.repo.d/myrepo.conf': before => Class["physical-server] # # Ensures that the yum repo is configured before any of the resource contain in the physical-server class. # Note you can't overide the dependency per-resource within class resource. # So this is somewhat less flexible but it is explicitly a resource to class level dependency. # } > > But is it possible to create requirements "tree" on per class basis? Maybe > inheritance will help (BTW, if I use "class A inherits B" does it guarantee > that B class resources will be processed before A class ones)? > Inheritence implies no order. So that won't help here. > > > Maybe there is some kind of wildcards so I can use "before => EVERYTHING" > in yum module resources as the number of the latter is much lower. > again before => Class['physical-server] should do the trick. I assume there is some ordering to the yum work within the class itself. Just put the relationship in the last resource that completes your yum configuration. > > > To summarize: I'd like to know is there any way to define dependencies not > in each resource definition, but rather for resources collection. Any advice > will be highly appreciated. > > Thanks in advance. > > -- > Alexander Pankratov > > -- Teyo Tyree :: www.reductivelabs.com :: +1.615.275.5066 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---