Class: Chef::Provider::Script
- Inherits:
-
Execute
- Object
- Chef::Provider
- Execute
- Chef::Provider::Script
- Defined in:
- lib/chef/provider/script.rb
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Attribute Summary
Attributes inherited from Chef::Provider
#action, #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
#load_current_resource, #whyrun_supported?
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!
Methods inherited from Chef::Provider
#action_nothing, build_from_file, #cleanup_after_converge, #converge, #cookbook_name, #define_resource_requirements, #events, #initialize, #load_current_resource, #node, #process_resource_requirements, #requirements, #resource_collection, #run_action, #whyrun_mode?, #whyrun_supported?
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::EnforceOwnershipAndPermissions
#access_controls, #enforce_ownership_and_permissions
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #platform_family?, #search, #value_for_platform, #value_for_platform_family
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 37 38 |
# 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 converge_by(nil) do # ensure script is unlinked at end of converge! unlink_script_file end end |
#script_file ⇒ Object
47 48 49 |
# File 'lib/chef/provider/script.rb', line 47 def script_file @script_file ||= Tempfile.open("chef-script") end |
#set_owner_and_group ⇒ Object
40 41 42 43 44 45 |
# File 'lib/chef/provider/script.rb', line 40 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
51 52 53 |
# File 'lib/chef/provider/script.rb', line 51 def unlink_script_file @script_file && @script_file.close! end |