Issue #21833 has been updated by Charlie Sharpsteen.

Status changed from Unreviewed to Ready for Documentation

The `tagged()` function is dependent on compilation order. Any class that is 
evaluated before the class that conditionally includes `'apache::ssl'` will not 
see the apache tag because the compiler has not processed the apache class far 
enough to add it (and the tags) to the catalog.

Luitzen van Gorkum wrote:
> It is possible two different modules need the same providing module (such as 
> apache::ssl). Because we can't include the same module twice we have to check 
> on that. That's where tagged() comes in.

`include some_class` can be called multiple times without issue. The class 
declaration form `class{'some_class': }` can only be used once per catalog. 
Enforcing a single declaration ensures only a single set of parameters are used 
in the case of parameterized classes.


> In my initial request it is just a little more than only includes, a 
> providing module has different actions when other modules are included. We 
> have a module providing a file whith owner root:root. When apache is loaded 
> this must be changed to root:apache. When apache isn't loaded the apache 
> group doesn't exists. That's why I tried to use tagged()

The most straight-forward means to accomplish this is to use Facter facts, 
Hiera data or an ENC to make this sort of classification available at the 
beginning of compilation. Then situations, such as file ownership, can be 
decided by referencing fixed classification data instead of relying on dynamic 
relationships that are affected by compilation order.

If providing node classification data at the start of compilation is not 
feasible, then you will need to ensure your "provider" classes declare 
relationships that cause them to be evaluated after the classes that affect 
their behavior. The [anchor 
pattern](http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html) 
may help with this.


> The defined() function is documented to be compilation order dependent, 
> tagged() wasn't....

We definitely need to update the documentation to be clear that tagged is also 
dependent on compilation order.

----------------------------------------
Bug #21833: tagged() does not work on conditionally includes
https://projects.puppetlabs.com/issues/21833#change-95763

* Author: Luitzen van Gorkum
* Status: Ready for Documentation
* Priority: Normal
* Assignee: 
* Category: functions
* Target version: 
* Affected Puppet version: 2.7.22
* Keywords: tagged
* Branch: 
----------------------------------------
When a module conditionally includes a class (to avoid multiple includes from 
different modules) like this:

<pre>
  if ! tagged('apache::ssl') { include apache::ssl }
</pre>

Then the tagged function in another module doesn't report the class as tagged:

<pre>
  if tagged('apache::ssl') {
    do something
  } else {
    do something else
  }
</pre>


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to