Greetings all, I''m running into an interesting problem that I''m hoping someone out there knows more about than I. Consider the following code: -------- class testa { notify { "note_testa": message => "Test A!"; "note2_testa": message => "Test A take 2!" } } class testb { notify { "note_testb": message => "Test B!" } } Notify<| tag == "testb" |> -> Notify<| tag == "testa" |> node puptest { include testa include testb } --------- In this case, what I''m trying to do is express the relationship that any notification in the testb class (more generally, tagged with ''testb'' – which any resource of the testb class should be, right?) should occur before any notification in the testa class. In inspecting the catalog and graph that results (relationships.dot), I would expect to see the following relationships represented: Notify[note_testb] -> Notify[note_testa] Notify[note_testb] -> Notify[note2_testa] However, I''m not seeing any relationships between the notifies at all - the graph is disjoint, and the messages appear in any order. "Hm," I thought to myself, "maybe this is because you can''t look for an individual tag like this in a collection, because the resource doesn''t just have one tag, it has a bunch of tags." But then I looked at the 2.6.3 source code, and there appears to be a special case for tag in collection expressions! If the LHS of the == condition says tag, it looks like that will trigger a check to see if the resource is tagged with the RHS value. So it looks to me like this usage of the collection/relationship syntax was anticipated. I note that if I change to Notify<| title == "note_testb" |> or just to simple resource references like Notify[note_testb], the relationship does take effect. But then, of course, it''s just a 1-1 relationship, so I might as well just write requires. I think this class-based and collection-based expression of relationships could be extremely powerful and useful. Has anybody managed to get anything like this working, or does anybody know a reason why this shouldn''t work? Thanks! -- O -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ian Ward Comfort
2010-Nov-18 09:56 UTC
Re: [Puppet Users] Of classes, tags, and collections
On 18 Nov 2010, at 1:06 AM, Owen Smith wrote:> I''m running into an interesting problem that I''m hoping someone out > there knows more about than I. > > Consider the following code: > > -------- > class testa { > notify { > "note_testa": message => "Test A!"; > "note2_testa": message => "Test A take 2!" > } > } > > class testb { > notify { "note_testb": message => "Test B!" } > } > > Notify<| tag == "testb" |> -> Notify<| tag == "testa" |> > > node puptest { > include testa > include testb > } > --------- > > In this case, what I''m trying to do is express the relationship that > any notification in the testb class (more generally, tagged with > ''testb'' – which any resource of the testb class should be, right?) > should occur before any notification in the testa class. In inspecting > the catalog and graph that results (relationships.dot), I would expect > to see the following relationships represented: > > Notify[note_testb] -> Notify[note_testa] > Notify[note_testb] -> Notify[note2_testa] > > However, I''m not seeing any relationships between the notifies at all > - the graph is disjoint, and the messages appear in any order. > > "Hm," I thought to myself, "maybe this is because you can''t look for > an individual tag like this in a collection, because the resource > doesn''t just have one tag, it has a bunch of tags." But then I looked > at the 2.6.3 source code, and there appears to be a special case for > tag in collection expressions! If the LHS of the == condition says > tag, it looks like that will trigger a check to see if the resource is > tagged with the RHS value. So it looks to me like this usage of the > collection/relationship syntax was anticipated. > > I note that if I change to Notify<| title == "note_testb" |> or just > to simple resource references like Notify[note_testb], the > relationship does take effect. But then, of course, it''s just a 1-1 > relationship, so I might as well just write requires. > > I think this class-based and collection-based expression of > relationships could be extremely powerful and useful. Has anybody > managed to get anything like this working, or does anybody know a > reason why this shouldn''t work?You may be running across something as simple as a slight variation on bug #4560: https://projects.puppetlabs.com/issues/4560 In short, implicit tag assignment does not seem to be reliable. -- Ian Ward Comfort <icomfort@stanford.edu> Systems Team Lead, Academic Computing Services, Stanford University -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Nov 18, 1:56 am, Ian Ward Comfort <icomf...@stanford.edu> wrote:> On 18 Nov 2010, at 1:06 AM, Owen Smith wrote: > > -------- > > class testa { > > notify { > > "note_testa": message => "Test A!"; > > "note2_testa": message => "Test A take 2!" > > } > > } > > > class testb { > > notify { "note_testb": message => "Test B!" } > > } > > > > Notify<| tag == "testb" |> -> Notify<| tag == "testa" |> > > > > node puptest { > > include testa > > include testb > > } > > --------- > > > > ...I would expect > > to see the following relationships represented: > > > Notify[note_testb] -> Notify[note_testa] > > Notify[note_testb] -> Notify[note2_testa] > > > > However, I''m not seeing any relationships between the notifies at all > > - the graph is disjoint, and the messages appear in any order. > > You may be running across something as simple as a slight variation on bug #4560: > > https://projects.puppetlabs.com/issues/4560 > > In short, implicit tag assignment does not seem to be reliable.Good call! Putting explicit tag declarations on the resources fixes the problem. Though the purpose here was to simplify my resource declarations and factor out certain releationships as a separate aspect, so this workaround doesn''t buy me much. Given that, I''ll call this a bug, and I''ll note the relationship to the issue above. (It''s a related issue but different because I''m not dealing with virtual resources.) Thanks! -- O -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.