On Wednesday, February 12, 2014 9:01:40 AM UTC-6, zerozer...@gmail.com wrote: > > Hi, > I'm using tags in resource defaults to define resource ordering inside a > single class, preventing at the same time dependency cycles with other > classes, like this: > > class myname::myclass { > > # defaults > User { tag => "this_class" } > File { tag => "this_class" } > Service { tag => "this_class" } > > # dependencies > User <| tag == "this_class" |> -> > File <| tag == "this_class" |> -> > Service <| tag == "this_class" |> > > # resources, many of each type > user { > ... > } > > file { > ... > } > > service { > ... > } > > } > > But this doesn't seem to work: I get errors, and by looking at the report > I can see that the errors are due to dependencies not being respected, e.g. > some service resources are applied before some file resources and so on. > > Am I missing anything? >
I think so. This looks related to https://tickets.puppetlabs.com/browse/PUP-1045. Moreover, resources get automatic tags that may support what you're after even easier than what you're trying to do. For example, this model might work: class myname::myclass { # no resource defaults needed # dependencies User <| tag == "myname::myclass" |> -> File <| tag == "myname::myclass" |> -> Service <| tag == "myname::myclass" |> ... } > > BTW, I was supposing there are no problems with "nested" dependencies, > right? > I mean, the class itself is part of a dependency chain together with other > classes, and the chain works fine. But I suppose there is no problem with > creating dependencies contained inside a class which is part of the higher > chain. > > You are mostly correct. There is no problem with resources being chained and the class or defined type instance containing them being part of a separate chain. Resources declared directly by a class or defined type instance are contained in their declaring class or defined type instance. Classes, however, are not resources, no matter how resource-like Puppet makes them appear. Classes declared via the 'include' function or the resource-like declaration syntax are not automatically contained. Where needed, they can be made contained via the new 'contain' function. Do note, however, that what you're specifically doing seems questionable, in that you are declaring many relationships that you probably don't need. For example, suppose your class manages both NTP and Puppet. You may have users 'ntp' and 'puppet', files '/etc/ntp.conf' and '/etc/puppet/puppet.conf', and services 'ntp' and 'puppet'. Why do you need a relationship between User['ntp'] and File['/etc/puppet/puppet.conf']? Unneeded relationships invite trouble. They make resource cycles more likely, and they make resource failures more impactful than they need to be. They may also make your catalogs larger and your Puppet runtimes longer. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0a699f15-621b-432b-807a-3c9d1606d241%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.