lib/opskeleton/deploy_scp.rb in opskeleton-0.8.9 vs lib/opskeleton/deploy_scp.rb in opskeleton-0.8.10
- old
+ new
@@ -1,11 +1,8 @@
-require 'configuration'
-conf = "#{ENV['HOME']}/.configuration.rb"
-raise "#{conf} not found, please create a conf file with a scp section" unless File.exists?(conf)
-require conf
+
module Opsk
class DeployScp < Thor::Group
include Thorable, Thor::Actions
argument :dest, :type => :string, :desc => 'dest'
@@ -14,22 +11,28 @@
def validate
check_root
end
+ def load_conf
+ require 'configuration'
+ conf = "#{ENV['HOME']}/.configuration.rb"
+ raise "#{conf} not found, please create a conf file with a scp section" unless File.exists?(conf)
+ require conf
+ end
def upload
require 'net/scp'
pkg = Opsk::Package.new
tar = "#{pkg.artifact_path}.tar.gz"
base = File.basename(tar)
if(File.exists?(tar))
begin
conf = Configuration.for('scp').send(dest.to_sym)
- port = conf.port || '22'
+ port = conf.port || '22'
Net::SSH.start(conf.host, conf.user, :port => port) do |session|
- session.scp.upload!(tar, conf.dest)
- end
+ session.scp.upload!(tar, conf.dest)
+ end
say("deployed #{base} to #{conf.user}@#{conf.host}:#{conf.dest}")
rescue Exception => e
say("failed to deploy due to #{e}")
end
else