Class: Opsk::DeployScp
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Opsk::DeployScp
show all
- Includes:
- Thorable, Thor::Actions
- Defined in:
- lib/opskeleton/deploy_scp.rb
Instance Method Summary
collapse
Methods included from Thorable
#artifact, #artifact_path, #check_root, included, #machines, #meta, #name, #type_of
Instance Method Details
#load_conf ⇒ Object
16
17
18
19
20
21
|
# File 'lib/opskeleton/deploy_scp.rb', line 16
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
|
#upload ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/opskeleton/deploy_scp.rb', line 23
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'
Net::SSH.start(conf.host, conf.user, :port => port) do |session|
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
say('package is missing please run opsk package first')
exit(1)
end
end
|
#validate ⇒ Object
12
13
14
|
# File 'lib/opskeleton/deploy_scp.rb', line 12
def validate
check_root
end
|