Class: Chef::Provider::Script
- Inherits:
-
Execute
- Object
- Chef::Provider
- Execute
- Chef::Provider::Script
- Defined in:
- lib/chef/provider/script.rb
Instance Attribute Summary
Attributes inherited from Chef::Provider
#current_resource, #new_resource, #run_context
Instance Method Summary collapse
- #action_run ⇒ Object
- #script_file ⇒ Object
- #set_owner_and_group ⇒ Object
- #unlink_script_file ⇒ Object
Methods inherited from Execute
Methods included from Mixin::ShellOut
Methods inherited from Chef::Provider
#action_nothing, build_from_file, #cookbook_name, #initialize, #load_current_resource, #node, #resource_collection
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #search, #value_for_platform
Constructor Details
This class inherits a constructor from Chef::Provider
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
Instance Method Details
#action_run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/chef/provider/script.rb', line 26 def action_run script_file.puts(@new_resource.code) script_file.close set_owner_and_group @new_resource.command("\"#{@new_resource.interpreter}\" #{@new_resource.flags} \"#{script_file.path}\"") super ensure unlink_script_file end |
#script_file ⇒ Object
45 46 47 |
# File 'lib/chef/provider/script.rb', line 45 def script_file @script_file ||= Tempfile.open("chef-script") end |
#set_owner_and_group ⇒ Object
38 39 40 41 42 43 |
# File 'lib/chef/provider/script.rb', line 38 def set_owner_and_group # FileUtils itself implements a no-op if +user+ or +group+ are nil # You can prove this by running FileUtils.chown(nil,nil,'/tmp/file') # as an unprivileged user. FileUtils.chown(@new_resource.user, @new_resource.group, script_file.path) end |
#unlink_script_file ⇒ Object
49 50 51 |
# File 'lib/chef/provider/script.rb', line 49 def unlink_script_file @script_file && @script_file.close! end |