Class: Dockage::SSH
- Inherits:
-
Object
- Object
- Dockage::SSH
- Defined in:
- lib/dockage/ssh.rb
Constant Summary collapse
- SSH_OPTS =
%w( StrictHostKeyChecking=no UserKnownHostsFile=/dev/null )
Class Method Summary collapse
Class Method Details
.connect(opts) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/dockage/ssh.rb', line 19 def connect(opts) set_ssh_command(opts) Dockage.debug(@command) system(@command) exit 0 end |
.execute(provision, opts) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dockage/ssh.rb', line 6 def execute(provision, opts) return Dockage.logger('Nothing to provide') unless provision set_ssh_command(opts) Dockage.logger("Provisioning #{ provision.map{ |k,v| "#{k.to_s.yellow}: #{v}" }.join }") execute = "#{@command} #{provision[:inline]}" if provision[:inline] if provision[:script] Dockage.error("File #{provision[:script].bold} is not exist") unless File.exist?(provision[:script]) execute = "cat #{provision[:script]} | #{@command}" end Dockage.verbose(execute) system(execute) end |
.set_ssh_command(opts) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dockage/ssh.rb', line 26 def set_ssh_command(opts) raise SSHOptionsError if !opts[:login] || !opts[:host] return if @command @command = which_ssh @command += SSH_OPTS.map { |opt| " -o #{opt}" }.join if SSH_OPTS.any? @command += " -A" if opts[:forward_agent] @command += " -i #{opts[:identity_file]}" if opts[:identity_file] @command += " #{opts[:login]}@#{opts[:host]}" @command += " -p #{opts[:port]}" if opts[:port] @command += " -q" unless Dockage.verbose_mode end |