From c2e2aafa267f9443fdc190670ebc977370e4c364 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Mon, 2 Dec 2019 14:21:22 -0800 Subject: [PATCH] (maint) Reset "tasks" setting after with_script_compiler The `Puppet::Pal.with_script_compiler` method sets the `Puppet[:tasks]` setting to true for the duration of the block, but never sets it back to its original state. This means that the mode of operation the process is in will be globally changed depending on whether this method has been called. The corresponding `with_catalog_compiler` method has similar behavior in setting `Puppet[:tasks]` to false, but it ensures that the setting is reset to its previous value when the method returns. We now copy that behavior in `with_script_compiler`. --- lib/puppet/pal/pal_impl.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/puppet/pal/pal_impl.rb b/lib/puppet/pal/pal_impl.rb index df2bb20d38a..870052bb504 100644 --- a/lib/puppet/pal/pal_impl.rb +++ b/lib/puppet/pal/pal_impl.rb @@ -83,6 +83,8 @@ def self.with_script_compiler( end end + previous_tasks_value = Puppet[:tasks] + previous_code_value = Puppet[:code] Puppet[:tasks] = true # After the assertions, if code_string is non nil - it has the highest precedence Puppet[:code] = code_string unless code_string.nil? @@ -90,6 +92,9 @@ def self.with_script_compiler( # If manifest_file is nil, the #main method will use the env configured manifest # to do things in the block while a Script Compiler is in effect main(manifest_file, facts, variables, :script, &block) + ensure + Puppet[:tasks] = previous_tasks_value + Puppet[:code] = previous_code_value end # Evaluates a Puppet Language script string.