Issue #8040 has been updated by Jeff McCune.

# Graph View #

To visualize the problem.  Please consider the graph produced when the work 
around is not used.

<pre>
class activemq {
  class { 'activemq::pacakge': }
  ->
  class { 'activemq::config': }
  ->
  class { 'activemq::service': }
}
</pre>

When the user declares this class in their node definitions, they want activemq 
to be managed after Java is managed and before MCollective is managed:

<pre>
node default {
  class { 'java': }
  ->
  class { 'activemq': }
  ->
  class { 'mcollective': }
}
</pre>

Here is the resulting graph with this code:

![The Problem](/attachments/1402/Anchor_no_relationships.png)

# The Work Around #

To work around the problem, the module author contains all of the classes in 
the MCollective Module using anchor resources:

<pre>
class activemq {
  anchor { 'activemq::begin': }
  ->
  class { 'activemq::pacakge': }
  ->
  class { 'activemq::config': }
  ->
  class { 'activemq::service': }
  ->
  anchor { 'activemq::end': }
}
</pre>

And we get the following graph.  Note the resources the end user has declared 
come after all of the resources in the activemq module.

![Anchor Work Around](/attachments/1403/Anchor_both_anchors.png)
----------------------------------------
Bug #8040: Classes should be able to contain other classes to provide a self 
contained module
https://projects.puppetlabs.com/issues/8040

Author: Jeff McCune
Status: Unreviewed
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 2.6.0
Keywords: anchor containment contain graph modules module self-contained 
dependency reuse usability forge
Branch: 


# Overview #

As a module author, I want to build collections of classes for end users 
shipped as a module.

As a module end-user, I want to manage resources before and that require the 
collection of classes as a self contained unit of functionality.

For example, the end user wants to use a module I write in the following way:

<pre>
node default {
  class { 'java': }
  ->
  class { 'activemq': }
  ->
  class { 'mcollective: }
}
</pre>

Where java, activemq, and mcollective are all discrete modules with multiple 
classes each.  For example, a each module has a class for the packages, a class 
for the configuration files, and a class for the running service if there is a 
service.

With Puppet 2.6, when a class declares another class, the classes are not 
related to each other in any way, containment or dependency.

# Expected Behavior #

The example illustrates the expectation that all resources in the activemq 
module are managed after all resources in the java module and before all 
resources in the mcollective module.

# Actual Behavior #

Without the Anchor Pattern, when class activemq::service is declared from 
within class activemq, the resources float away and are not transitively 
related to java or mcollective.

# Suggested Implementation #

It has been expressed that it may be a viable solution for module authors to be 
able to specify containment edges in the graph from within the Puppet DSL.  
With Puppet 2.6.x and 2.7.x this is not possible.  The Anchor Pattern works 
around this problem by specifying relationship edges to a resource contained 
within the composite class.

# Work Around #

The Anchor Pattern is the current work around for Puppet 2.6.x  When a class 
declares other classes, it should contain them using this pattern:

<pre>
class activemq {

  anchor { 'activemq::begin': }
  anchor { 'activemq::end': }

  class { 'activemq::package':
    require => Anchor['activemq::begin'],
  }
  class { 'activemq::config':
    require => Class['activemq::config'],
    notify => Class['activemq::service'],
  }
  class { 'activemq::service':
    before => Anchor['activemq::end'],
  }

}
</pre>

-- 
Jeff McCune
Puppet Labs
@0xEFF



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to puppet-bugs@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-bugs+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to