On Thu, Oct 11, 2012 at 8:32 AM, Mohit Chawla <mohit.chawla.bin...@gmail.com
> wrote:

> Hello,
>
> On Thu, Oct 11, 2012 at 8:39 PM, Jeff McCune <j...@puppetlabs.com> wrote:
> > Yes, this is a perfect example of when to employ the anchor pattern. It's
> > also a perfect example of the bug we need to fix in puppet.
> >
> > Class foo, bar, an baz will "float off" in the relationship graph because
> > class wrapper contains no other resources to "anchor" them down.
> >
> > If you add a begin an end anchor resources to class wrapper and establish
> > relationships between them and the three contained classes, it should
> work
> > as you expect
> >
> > I will give a concrete example, if you wish, once I get to my desk.
> >
>
> Thank you for the response, an example for the wrapper class would
> indeed be nice.
>
> And although this might be a difficult question to give a generalized
> (or rather, a slightly less technical) answer, but this behaviour of
> floating off of the graph, is it easy to attribute this to particular
> scenarios ? For example, as you noticed in the previous replies - Luke
> suggested this for nested classes, while llowder thought this was a
> perfect example, as so you ! :)
>
> Also, @Luke, your suggestion to be explicit about the relationships like
> so:
> class wrapper {
>   include foo
>   include bar
>   class["foo"]->Class["wrapper"]
>   class["bar"]->Class["wrapper"]
> }
>
> node x {
>   include someclass
>   include wrapper
>   class["someclass"]->Class["wrapper"]
> }
>
> ... didn't work. "someclass" was still applied after the wrapper
> class's classes.



Here's how I'd do it:

class wrapper {
  anchor { 'wrapper::begin': }
  anchor { 'wrapper::end':
    require => Anchor['wrapper::begin'],
  }

  # Note, foo, bar, baz still do not have relationships between one another.
  class { foo:
    require => Anchor['wrapper::begin'],
    before => Anchor['wrapper::end'],
  }
  class { bar:
    require => Anchor['wrapper::begin'],
    before => Anchor['wrapper::end'],
  }
  class { baz:
    require => Anchor['wrapper::begin'],
    before => Anchor['wrapper::end'],
  }
}

And a node like:

node x {
  include someclass
  include wrapper
  Class["someclass"]->Class["wrapper"]
}

-- 
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.

Reply via email to