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 {# defaultsUser { tag => "this_class" }File { tag => "this_class" }Service { tag => "this_class" }# dependenciesUser <| tag == "this_class" |> ->File <| tag == "this_class" |> ->Service <| tag == "this_class" |># resources, many of each typeuser {...}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?
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.
Moreover, resources get automatic tags that may support what you're after even easier than what you're trying to do.
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.
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# dependenciesUser <| tag == "myname::myclass" |> ->File <| tag == "myname::myclass" |> ->Service <| tag == "myname::myclass" |>}
...
and
Both operands must be valid search expressions.
For a given resource, this operator will match if both of the operands would match for that resource.
On Friday, February 14, 2014 3:55:29 PM UTC+1, Felix.Frank wrote:On 02/14/2014 03:52 PM, zerozer...@gmail.com wrote:
> File <| (tag == "myname::myclass") and (tag == "post_exec") |>
While this looks sane, this syntax is not yet supported. Your collectors
must use trivial expressions of the form "a == b".Sorry, what do you mean? I'm using two trivial expressions AFAICT.Or are you referring to the "and"ing of two search expressions?
Yes, I believe the combination of two simple expressions into a complex one via the "and" operator is what Felix was referring to. Despite the docs, it might be worthwhile to play around a bit to test the outlines of the problem:
- Does it really work at all (for your version of the master)? The docs are fairly reliable, but if you happen not to be on the latest Puppet then they might not apply. Also, Puppet occasionally suffers regressions (which typically are fixed pretty quickly once PL is made aware of them).
- Is the failure related specifically to the 'tag' property, which is a bit special?
- Is the failure related to having two conditions on the same resource parameter?
Or we could return to my original remark that what you're doing is a bit questionable. Whether your code really ought to work notwithstanding, your manifest set would be more robust if you wrapped all the managed resources related to each piece of software into its own class or defined-type instance. If you have a lot of services and your declarations are consistent in form, then using a common defined type and one instance per (user, file, service) triple would make your manifests even cleaner, and allow you to be more precise with relationships, too.