Issue #3845 has been updated by Charlie Sharpsteen.

Subject changed from Resource defaults and class-level tags are applied after 
collectors are evaluated to Resource defaults and automatic tags are applied 
after collectors are evaluated
Status changed from Investigating to Accepted
Assignee deleted (Charlie Sharpsteen)

What is going on here is that automatic tags and resource defaults are applied 
by the compiler during the [`finish` 
stage](https://github.com/puppetlabs/puppet/blob/3.2.0/lib/puppet/parser/compiler.rb#L105)
 which is executed after the [`evaluate_generators` 
stage](https://github.com/puppetlabs/puppet/blob/3.2.0/lib/puppet/parser/compiler.rb#L103)
 where collectors are evaluated. Additionally, [the step that adds 
automatic_tags](https://github.com/puppetlabs/puppet/blob/3.2.0/lib/puppet/parser/resource.rb#L246-L250)
 from parent scopes is not selective at all---it performs a wholesale copy of 
all tags. Therefore, a notify resource defined inside a class ends up tagged as 
both a class resource and a notify resource which is probably not the intended 
behavior as this makes it difficult to use tags to filter by resource type.

There is also another issue with resource defaults described in #5761 that 
exacerbates this situation.

----------------------------------------
Bug #3845: Resource defaults and automatic tags are applied after collectors 
are evaluated
https://projects.puppetlabs.com/issues/3845#change-91007

* Author: Jonathan Booth
* Status: Accepted
* Priority: Normal
* Assignee: 
* Category: compiler
* Target version: 
* Affected Puppet version: 0.25.4
* Keywords: resource_default automatic_tagging collectors customer
* Branch: 
----------------------------------------
Resources (and virtual resources) are not having their classes declared tags 
correctly applied. ("Add the specified tags to the containing class or 
definition. All contained objects will then acquire that tag, also." ref: 
http://docs.puppetlabs.com/references/latest/function.html#tag)

<pre>
class foo {
    tag 'notworking'
    notify { "I'm untagged": }
    notify { "I'm tagged": tag => "notworking" }
}
include foo
Notify <| tag == "notworking" |> { message => "I am though" }
</pre>

Results in:

<pre>
mauve /home/jbooth > puppet tagmagic.pp
notice: I am though
notice: //foo/Notify[I'm tagged]/message: defined 'message' as 'I am though'
notice: I'm untagged
notice: //foo/Notify[I'm untagged]/message: defined 'message' as 'I'm untagged'
</pre>

You can change the 'tag == "foo"' and life doesn't get any better. The neither 
notify gets the message changed.

<pre>
mauve /home/jbooth > tail -1 tagmagic.pp 
Notify <| tag == "foo" |> { message => "I am though" }
mauve /home/jbooth > puppet tagmagic.pp
notice: I'm untagged
notice: //foo/Notify[I'm untagged]/message: defined 'message' as 'I'm untagged'
notice: I'm tagged
notice: //foo/Notify[I'm tagged]/message: defined 'message' as 'I'm tagged'
</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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to