diff options
-rw-r--r-- | lib/chef/dsl/declare_resource.rb | 2 | ||||
-rw-r--r-- | lib/chef/run_context.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb index ed3083e1ca..2ebef98bd4 100644 --- a/lib/chef/dsl/declare_resource.rb +++ b/lib/chef/dsl/declare_resource.rb @@ -47,7 +47,7 @@ class Chef when Chef::RunContext rc when :root - Chef.run_context + run_context.root_run_context when :parent run_context.parent_run_context else diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index 5d29f766c9..0ebf1b228d 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -85,6 +85,19 @@ class Chef attr_reader :parent_run_context # + # The root run context. + # + # @return [Chef::RunContext] The root run context. + # + def root_run_context + rc = self + until rc.parent_run_context.nil? + rc = rc.parent_run_context + end + rc + end + + # # The collection of resources intended to be converged (and able to be # notified). # |