Class: Bolt::Transport::SSH::Connection::RemoteTempdir
- Inherits:
-
Object
- Object
- Bolt::Transport::SSH::Connection::RemoteTempdir
- Defined in:
- lib/bolt/transport/ssh/connection.rb
Instance Method Summary collapse
- #chown(owner) ⇒ Object
- #delete ⇒ Object
-
#initialize(node, path) ⇒ RemoteTempdir
constructor
A new instance of RemoteTempdir.
- #to_s ⇒ Object
Constructor Details
#initialize(node, path) ⇒ RemoteTempdir
Returns a new instance of RemoteTempdir.
11 12 13 14 15 16 |
# File 'lib/bolt/transport/ssh/connection.rb', line 11 def initialize(node, path) @node = node @owner = node.user @path = path @logger = node.logger end |
Instance Method Details
#chown(owner) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bolt/transport/ssh/connection.rb', line 22 def chown(owner) return if owner.nil? || owner == @owner @owner = owner result = @node.execute(['chown', '-R', "#{@owner}:", @path], sudoable: true, run_as: 'root') if result.exit_code != 0 = "Could not change owner of '#{@path}' to #{@owner}: #{result.stderr.string}" raise Bolt::Node::FileError.new(, 'CHOWN_ERROR') end end |
#delete ⇒ Object
33 34 35 36 37 38 |
# File 'lib/bolt/transport/ssh/connection.rb', line 33 def delete result = @node.execute(['rm', '-rf', @path], sudoable: true, run_as: @owner) if result.exit_code != 0 @logger.warn("Failed to clean up tempdir '#{@path}': #{result.stderr.string}") end end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/bolt/transport/ssh/connection.rb', line 18 def to_s @path end |