puppetlabs/puppet — pull request #1706 by MrStaticVoid (2013-06-13 04:35:05+00:00)
Title: (#7793) Let resources inherit the noop parameter from their surrounding class

The metaparameter documentation[1] says that metaparameters, including
noop, work with any resource type. Therefore, the natural assumption
would be to think that something like:

class foo {
...many resources...
}

class { 'foo':
noop => true,
}

will actually put all of the functionality of Class[foo] into noop
mode. This would be especially useful when combined with inheritance
and overriding:

node basenode {
class { 'foo':
noop => true,
}
}

node 'foo.example.com' inherits basenode {
Class[foo] {
noop => false,
}
}

(or the other way around, if you have a class enabled everywhere, and
you want to disable it on certain smaller sets of hosts.)

This doesn't work in the current code.

This patch does two things to fix the issue:

1. It reorders the resource graph during parsing and compile time to
properly nest classes included by other classes. This is necessary for
allowing resources of classes included by other classes to inherit the
noop attribute properly. This could be a potentially risky change, but
it passes all of the tests, it's working in my environment, and it
doesn't change any scoping rules.

2. It modifies the Puppet::Type.noop? function to look at the parent's
noop value if the type itself doesn't have noop defined. This
conveniently allows resources to override the noop value set at a
higher level.

This patch also adds a couple of new test cases to validate the noop
parameter inheritance.

[1] http://docs.puppetlabs.com/references/latest/metaparameter.html