|
A minimum re-production case for this behavior consists of a defined type and a class which declares a noop resource of that time type:
# atype.pp
|
define noop_test::atype(
|
$content_string = 'some content',
|
) {
|
|
file{"/tmp/$title":
|
ensure => file,
|
content => $content_string,
|
}
|
|
}
|
# init.pp
|
class noop_test {
|
|
noop_test::atype{'defined_by_class': noop => true}
|
|
}
|
The bug can be examined by declaring both a noop resource and the noop_test class inside of a node definition:
# site.pp
|
node default {
|
include noop_test
|
noop_test::atype{'defined_in_node': noop => true}
|
}
|
When the agent is run, the file resource declared by Atype[defined_in_node] has the expected value of noop => true. However, the file resource declared by Atype[defined_by_class] does not receive a noop => true parameter:
# puppet agent -t
|
|
Info: Retrieving pluginfacts
|
Info: Retrieving plugin
|
Info: Caching catalog for poss-head-master.puppetdebug.vlan
|
Info: Applying configuration version '1417630575'
|
|
Notice: /Stage[main]/Noop_test/Noop_test::Atype[defined_by_class]/File[/tmp/defined_by_class]/ensure: defined content as '{md5}9893532233caff98cd083a116b013c0b'
|
|
Notice: /Stage[main]/Main/Node[default]/Noop_test::Atype[defined_in_node]/File[/tmp/defined_in_node]/ensure: current_value absent, should be file (noop)
|
Notice: Noop_test::Atype[defined_in_node]: Would have triggered 'refresh' from 1 events
|
Notice: Node[default]: Would have triggered 'refresh' from 1 events
|
Notice: Class[Main]: Would have triggered 'refresh' from 1 events
|
|
Notice: Applied catalog in 0.03 seconds
|
The root of the issue is that the compiler sets metaparameters, such as noop, by walking a containment graph [rooted at Class[main]|https://github.com/puppetlabs/puppet/blob/3.7.3/lib/puppet/parser/compiler.rb#L476-L479]. This picks up all resources declared at node scope. However due to the tendency of classes to float free, unless anchored by the contain function, the add_resource_metaparams step of the compiler will miss all resources defined within classes.
A possible fix would be to change add_resource_metaparams such that walks the list of Stage resources and walks each containment graph rooted at a stage. This should produce the correct behavior as all free floating classes are contained by Stage[main].
|