lib/chef/provider/script.rb in chef-11.4.4 vs lib/chef/provider/script.rb in chef-11.6.0.hotfix.1
- old
+ new
@@ -21,17 +21,22 @@
class Chef
class Provider
class Script < Chef::Provider::Execute
+ def initialize(new_resource, run_context)
+ super
+ @code = @new_resource.code
+ end
+
def action_run
- script_file.puts(@new_resource.code)
+ script_file.puts(@code)
script_file.close
set_owner_and_group
- @new_resource.command("\"#{@new_resource.interpreter}\" #{@new_resource.flags} \"#{script_file.path}\"")
+ @new_resource.command("\"#{interpreter}\" #{flags} \"#{script_file.path}\"")
super
converge_by(nil) do
# ensure script is unlinked at end of converge!
unlink_script_file
end
@@ -50,8 +55,15 @@
def unlink_script_file
@script_file && @script_file.close!
end
+ def interpreter
+ @new_resource.interpreter
+ end
+
+ def flags
+ @new_resource.flags
+ end
end
end
end