Module: Chef::Mixin::TrainOrShell

Includes:
PowershellOut, ShellOut
Included in:
DSL::Universal, GuardInterpreter::DefaultGuardInterpreter, Provider::Execute
Defined in:
lib/chef/mixin/train_or_shell.rb

Instance Method Summary collapse

Methods included from PowershellOut

#powershell_out, #powershell_out!

Methods included from WindowsArchitectureHelper

#assert_valid_windows_architecture!, #disable_wow64_file_redirection, #forced_32bit_override_required?, #is_i386_process_on_x86_64_windows?, #node_supports_windows_architecture?, #node_windows_architecture, #restore_wow64_file_redirection, #valid_windows_architecture?, #with_os_architecture, #wow64_architecture_override_required?, #wow64_directory

Methods included from ShellOut

apply_default_env, maybe_add_timeout, #shell_out, #shell_out!

Methods included from PathSanity

#enforce_path_sanity, #sanitized_path

Instance Method Details

#train_or_powershell(*args, **opts) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/chef/mixin/train_or_shell.rb', line 50

def train_or_powershell(*args, **opts)
  if Chef::Config.target_mode?
    run_context.transport_connection.run_command(args)
    train_to_shellout_result(result.stdout, result.stderr, result.exit_status)
  else
    powershell_out(*args)
  end
end

#train_or_powershell!(*args, **opts) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/chef/mixin/train_or_shell.rb', line 59

def train_or_powershell!(*args, **opts)
  if Chef::Config.target_mode?
    result = run_context.transport_connection.run_command(args)
    raise Mixlib::ShellOut::ShellCommandFailed, "Unexpected exit status of #{result.exit_status} running #{args}" if result.exit_status != 0
    train_to_shellout_result(result.stdout, result.stderr, result.exit_status)
  else
    powershell_out!(*args)
  end
end

#train_or_shell(*args, **opts) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/chef/mixin/train_or_shell.rb', line 31

def train_or_shell(*args, **opts)
  if Chef::Config.target_mode?
    result = run_context.transport_connection.run_command(args)
    train_to_shellout_result(result.stdout, result.stderr, result.exit_status)
  else
    shell_out(*args, opts)
  end
end

#train_or_shell!(*args, **opts) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/chef/mixin/train_or_shell.rb', line 40

def train_or_shell!(*args, **opts)
  if Chef::Config.target_mode?
    result = run_context.transport_connection.run_command(*args)
    raise Mixlib::ShellOut::ShellCommandFailed, "Unexpected exit status of #{result.exit_status} running #{args}" if result.exit_status != 0
    train_to_shellout_result(result.stdout, result.stderr, result.exit_status)
  else
    shell_out!(*args, opts)
  end
end