Module: Crew::Context::Vagrant
- Includes:
- SSH
- Defined in:
- lib/crew/context/vagrant.rb
Instance Method Summary
collapse
Methods included from SSH
#cd, #current_dir, #reconnect!, #save_data, #save_file, #sh_raw, #sh_with_code
Instance Method Details
#start_shell ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/crew/context/vagrant.rb', line 6
def start_shell
@config_path = "/tmp/vagrant-config-#{$$}"
`vagrant ssh-config > #{@config_path}`
raise unless $?.success?
connect_opts = {}
user, host = nil, nil
Net::SSH::Config.load(@config_path, "default").each do |key, value|
case key
when 'user' then user = value
when 'hostname' then host = value
when 'port' then connect_opts[:port] = Integer(value)
when 'identityfile' then connect_opts[:keys] = value.first
when 'identitiesonly' then connect_opts[:keys_only] = value
when 'host', 'userknownhostsfile', 'stricthostkeychecking', 'passwordauthentication'
else warn "don't know #{key.inspect}"; exit(1)
end
end
@_shell = Net::SSH.start(host, user, connect_opts)
end
|
#stop_shell ⇒ Object
27
28
29
30
|
# File 'lib/crew/context/vagrant.rb', line 27
def stop_shell
@_shell.close if @_shell
File.unlink(@config_path)
end
|