Class: Bolt::Transport::Local

Inherits:
Sudoable show all
Defined in:
lib/bolt/transport/local.rb,
lib/bolt/transport/local/shell.rb

Defined Under Namespace

Classes: Shell

Constant Summary collapse

OPTIONS =
{
  "interpreters"    => "A map of an extension name to the absolute path of an executable, "\
                        "enabling you to override the shebang defined in a task executable. The "\
                        "extension can optionally be specified with the `.` character (`.py` and "\
                        "`py` both map to a task executable `task.py`) and the extension is case "\
                        "sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
                        "Bolt Ruby interpreter by default.",
  "run-as"          => "A different user to run commands as after login.",
  "run-as-command"  => "The command to elevate permissions. Bolt appends the user and command "\
                        "strings to the configured `run-as-command` before running it on the target. "\
                        "This command must not require an interactive password prompt, and the "\
                        "`sudo-password` option is ignored when `run-as-command` is specified. The "\
                        "`run-as-command` must be specified as an array.",
  "sudo-executable" => "The executable to use when escalating to the configured `run-as` user. This "\
                        "is useful when you want to escalate using the configured `sudo-password`, since "\
                        "`run-as-command` does not use `sudo-password` or support prompting. The command "\
                        "executed on the target is `<sudo-executable> -S -u <user> -p custom_bolt_prompt "\
                        "<command>`. **This option is experimental.**",
  "sudo-password"   => "Password to use when changing users via `run-as`.",
  "tmpdir"          => "The directory to copy and execute temporary files."
}.freeze

Constants inherited from Base

Base::ENVIRONMENT_METHODS, Base::STDIN_METHODS

Instance Attribute Summary

Attributes inherited from Base

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sudoable

#make_wrapper_stringio, #run_command, #run_script, #run_task, sudo_prompt, #upload, validate_sudo_options

Methods inherited from Base

#assert_batch_size_one, #batch_command, #batch_connected?, #batch_script, #batch_task, #batch_upload, #batches, #default_input_method, default_options, #envify_params, filter_options, #initialize, #run_command, #run_script, #run_task, #select_implementation, #select_interpreter, #unwrap_sensitive_args, #upload, #with_events

Constructor Details

This class inherits a constructor from Bolt::Transport::Base

Class Method Details

.optionsObject



28
29
30
# File 'lib/bolt/transport/local.rb', line 28

def self.options
  OPTIONS.keys
end

.validate(options) ⇒ Object



36
37
38
# File 'lib/bolt/transport/local.rb', line 36

def self.validate(options)
  validate_sudo_options(options)
end

Instance Method Details

#connected?(_targets) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/bolt/transport/local.rb', line 45

def connected?(_targets)
  true
end

#provided_featuresObject



32
33
34
# File 'lib/bolt/transport/local.rb', line 32

def provided_features
  ['shell']
end

#with_connection(target, *_args) {|conn| ... } ⇒ Object

Yields:

  • (conn)


40
41
42
43
# File 'lib/bolt/transport/local.rb', line 40

def with_connection(target, *_args)
  conn = Shell.new(target)
  yield conn
end