Class: Chef::Provider::Sudo

Inherits:
Chef::Provider show all
Defined in:
lib/chef-sudo.rb

Instance Method Summary collapse

Instance Method Details

#action_executeObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/chef-sudo.rb', line 70

def action_execute
  command = ["sudo"]
  command << "-u #{@new_resource.user}" if @new_resource.user
  command << "-g #{@new_resource.group}" if @new_resource.group
  command << "-i" if @new_resource.
  
  # changed " to ' to support `command`
  if @new_resource.cwd
    command << %Q{ bash -c 'cd #{@new_resource.cwd} && #{@new_resource.command}'}
  else
    command << %Q{ bash -c '#{@new_resource.command}'}
  end

  options = {:command => command.join(' ')}
  options[:environment] = @new_resource.environment if @new_resource.environment

  Chef::Mixin::Command.run_command(options)
  Chef::Log.info "Ran sudo [#{@new_resource.name}]"
end

#load_current_resourceObject



67
68
# File 'lib/chef-sudo.rb', line 67

def load_current_resource
end