Class: Promote::NodeShell::SshShell
Instance Attribute Summary
Attributes inherited from BaseShell
#node, #vault
Instance Method Summary
collapse
Methods inherited from BaseShell
#converge?, #initialize
Instance Method Details
#execute(command, ui = nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/promote/node_shell/ssh_shell.rb', line 12
def execute(command, ui = nil)
exit_code = nil
out = []
session.open_channel do |channel|
channel.request_pty
channel.exec(command) do |_ch, _success|
channel.on_data do |_ch, data|
ui.info(data) if ui
out << data
end
channel.on_extended_data do |_ch, _type, data|
ui.info(data) if ui
out << data
end
channel.on_request("exit-status") do |_ch, data|
exit_code = data.read_long
end
end
end
session.loop
exit_code
end
|
#session ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/promote/node_shell/ssh_shell.rb', line 4
def session
@session ||= Net::SSH.start(
node.ipaddress,
'root',
password: vault.root_password
)
end
|