Module: Kitchen::ShellOut
- Included in:
- Driver::Base, Driver::Exec, Driver::SSHBase, LifecycleHook::Local, Provisioner::Chef::Policyfile, Transport::Exec::Connection
- Defined in:
- lib/kitchen/shell_out.rb
Overview
Mixin that wraps a command shell out invocation, providing a #run_command method.
Defined Under Namespace
Classes: ShellCommandFailed
Instance Method Summary collapse
-
#run_command(cmd, options = {}) ⇒ String
Executes a command in a subshell on the local running system.
Instance Method Details
#run_command(cmd, options = {}) ⇒ String
Executes a command in a subshell on the local running system.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/kitchen/shell_out.rb', line 57 def run_command(cmd, = {}) if .fetch(:use_sudo, false) cmd = "#{.fetch(:sudo_command, "sudo -E")} #{cmd}" end subject = "[#{.fetch(:log_subject, "local")} command]" debug("#{subject} BEGIN (#{cmd})") sh = Mixlib::ShellOut.new(cmd, shell_opts()) sh.run_command debug("#{subject} END #{Util.duration(sh.execution_time)}") sh.error! sh.stdout rescue Mixlib::ShellOut::ShellCommandFailed => ex raise ShellCommandFailed, ex. rescue Exception => error # rubocop:disable Lint/RescueException error.extend(Kitchen::Error) raise end |