simple_deploy 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +30 -0
- data/lib/simple_deploy/artifact.rb +4 -3
- data/lib/simple_deploy/cli/variables.rb +1 -1
- data/lib/simple_deploy/cli.rb +50 -4
- data/lib/simple_deploy/config.rb +28 -10
- data/lib/simple_deploy/logger.rb +4 -0
- data/lib/simple_deploy/stack/deployment.rb +94 -0
- data/lib/simple_deploy/stack/stack_attribute_formater.rb +6 -9
- data/lib/simple_deploy/stack.rb +66 -25
- data/lib/simple_deploy/version.rb +1 -1
- data/lib/simple_deploy.rb +0 -1
- data/simple_deploy.gemspec +1 -1
- metadata +15 -14
- data/lib/simple_deploy/deployment.rb +0 -104
data/CHANGELOG
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
## v0.3.0:
|
2
|
+
|
3
|
+
* Updating to new ~/.simpledeploy.yml format.
|
4
|
+
|
5
|
+
artifacts:
|
6
|
+
chef_repo:
|
7
|
+
bucket_prefix: prefix_to_bucket
|
8
|
+
domain: name_of_object
|
9
|
+
app:
|
10
|
+
bucket_prefix: prefix_to_bucket
|
11
|
+
domain: name_of_object
|
12
|
+
cookbooks:
|
13
|
+
bucket_prefix: prefix_to_bucket
|
14
|
+
|
15
|
+
environments:
|
16
|
+
preprod_shared_us-west-1:
|
17
|
+
access_key: XXX
|
18
|
+
secret_key: YYY
|
19
|
+
region: us-west-1
|
20
|
+
infrastructure_us-west-1:
|
21
|
+
access_key: XXX
|
22
|
+
secret_key: YYY
|
23
|
+
region: us-west-1
|
24
|
+
infrastructure_us-east-1:
|
25
|
+
access_key: XXX
|
26
|
+
secret_key: YYY
|
27
|
+
region: us-east-1
|
28
|
+
|
29
|
+
* Adding locking to deployment.
|
30
|
+
* Added limit to number of events coming out with -l flag.
|
@@ -7,6 +7,7 @@ module SimpleDeploy
|
|
7
7
|
@id = args[:id]
|
8
8
|
@name = args[:name]
|
9
9
|
@region = args[:region]
|
10
|
+
@domain = @config.artifact_domain @name
|
10
11
|
|
11
12
|
@bucket = "#{@bucket_prefix}-#{@region}"
|
12
13
|
@key = "#{@id}.tar.gz"
|
@@ -23,15 +24,15 @@ module SimpleDeploy
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def s3_url
|
26
|
-
"s3://#{@bucket}/#{@
|
27
|
+
"s3://#{@bucket}/#{@domain}/#{@key}"
|
27
28
|
end
|
28
29
|
|
29
30
|
def http_url
|
30
|
-
"http://#{s3_endpoints[@region]}/#{@bucket}/#{@
|
31
|
+
"http://#{s3_endpoints[@region]}/#{@bucket}/#{@domain}/#{@key}"
|
31
32
|
end
|
32
33
|
|
33
34
|
def https_url
|
34
|
-
"https://#{s3_endpoints[@region]}/#{@bucket}/#{@
|
35
|
+
"https://#{s3_endpoints[@region]}/#{@bucket}/#{@domain}/#{@key}"
|
35
36
|
end
|
36
37
|
|
37
38
|
def s3_endpoints
|
data/lib/simple_deploy/cli.rb
CHANGED
@@ -28,11 +28,47 @@ Attributes are specified as '=' seperated key value pairs. Multiple can be spec
|
|
28
28
|
|
29
29
|
simple_deploy create -t ~/my-template.json -e my-env -n test-stack -a arg1=val1 -a arg2=vol2
|
30
30
|
|
31
|
+
You must setup a simple_deploy.yaml file in your home directory. Format as follows:
|
32
|
+
|
33
|
+
artifacts:
|
34
|
+
chef_repo:
|
35
|
+
domain: app_specific_domain
|
36
|
+
bucket_prefix: chef-bucket-prefix
|
37
|
+
app:
|
38
|
+
domain: app_specific_app
|
39
|
+
bucket_prefix: app-bucket-prefix
|
40
|
+
cookbooks:
|
41
|
+
domain: app_specific_cookbooks
|
42
|
+
bucket_prefix: cookbooks-bucket-prefix
|
43
|
+
|
44
|
+
environments:
|
45
|
+
preprod_shared_us_west_1:
|
46
|
+
access_key: XXXXXXXXXXXXXXXXXXX
|
47
|
+
secret_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
48
|
+
region: us-west-1
|
49
|
+
infrastructure_us_west_1:
|
50
|
+
access_key: XXXXXXXXXXXXXXXXXXX
|
51
|
+
secret_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
52
|
+
region: us-west-1
|
53
|
+
infrastructure_us_west_2:
|
54
|
+
access_key: XXXXXXXXXXXXXXXXXXX
|
55
|
+
secret_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
56
|
+
region: us-west-2
|
57
|
+
|
58
|
+
Bucket prefixes will append -us-west-1 (or appropriate region) when deploying based on the environment.
|
59
|
+
|
60
|
+
For example app-bucket-prefix will be tranlated to app-bucket-prefix-us-west-1.
|
61
|
+
|
62
|
+
The domain is the specific domain that is set when the artifact is created by heirloom.
|
63
|
+
|
31
64
|
EOS
|
32
65
|
opt :help, "Display Help"
|
33
66
|
opt :attributes, "= seperated attribute and it's value", :type => :string,
|
34
67
|
:multi => true
|
35
68
|
opt :environment, "Set the target environment", :type => :string
|
69
|
+
opt :force, "Force a deployment to proceed"
|
70
|
+
opt :limit, "Add limit to results returned by events.", :type => :integer,
|
71
|
+
:default => 3
|
36
72
|
opt :name, "Stack name to manage", :type => :string
|
37
73
|
opt :template, "Path to the template file", :type => :string
|
38
74
|
end
|
@@ -56,11 +92,19 @@ EOS
|
|
56
92
|
end
|
57
93
|
end
|
58
94
|
|
95
|
+
@stacks = Stackster::StackLister.new(:config => @config).all
|
96
|
+
@logger = SimpleDeployLogger.new
|
97
|
+
|
59
98
|
case @cmd
|
60
99
|
when 'create', 'delete', 'deploy', 'destroy', 'instances',
|
61
100
|
'status', 'attributes', 'events', 'resources',
|
62
101
|
'outputs', 'template', 'update', 'parameters'
|
63
|
-
|
102
|
+
|
103
|
+
unless @stacks.include? @opts[:name]
|
104
|
+
@logger.error "Stack '#{@opts[:name]}' does not exist."
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
|
64
108
|
@stack = Stack.new :environment => @opts[:environment],
|
65
109
|
:name => @opts[:name],
|
66
110
|
:config => @config,
|
@@ -78,7 +122,7 @@ EOS
|
|
78
122
|
@stack.destroy
|
79
123
|
@logger.info "#{@opts[:name]} destroyed."
|
80
124
|
when 'deploy'
|
81
|
-
@stack.deploy
|
125
|
+
@stack.deploy @opts[:force]
|
82
126
|
when 'environments'
|
83
127
|
Config.new.environments.keys.each { |e| puts e }
|
84
128
|
when 'update'
|
@@ -87,11 +131,13 @@ EOS
|
|
87
131
|
when 'instances'
|
88
132
|
@stack.instances.each { |s| puts s }
|
89
133
|
when 'list'
|
90
|
-
puts
|
134
|
+
puts @stacks
|
91
135
|
when 'template'
|
92
136
|
jj @stack.template
|
93
|
-
when '
|
137
|
+
when 'outputs', 'resources', 'status', 'parameters'
|
94
138
|
puts (@stack.send @cmd.to_sym).to_yaml
|
139
|
+
when 'events'
|
140
|
+
puts (@stack.events @opts[:limit]).to_yaml
|
95
141
|
else
|
96
142
|
puts "Unknown command. Use -h for help."
|
97
143
|
end
|
data/lib/simple_deploy/config.rb
CHANGED
@@ -8,17 +8,34 @@ module SimpleDeploy
|
|
8
8
|
self.logger = args[:logger] ||= SimpleDeployLogger.new
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
self.config = YAML::load( File.open( config_file ) )
|
11
|
+
def artifacts
|
12
|
+
['chef_repo', 'cookbooks', 'app']
|
14
13
|
end
|
15
14
|
|
16
|
-
def
|
17
|
-
|
15
|
+
def artifact_deploy_variable(artifact)
|
16
|
+
name_to_variable_map = { 'chef_repo' => 'CHEF_REPO_URL',
|
17
|
+
'app' => 'APP_URL',
|
18
|
+
'cookbooks' => 'COOKBOOKS_URL' }
|
19
|
+
name_to_variable_map[artifact]
|
20
|
+
end
|
21
|
+
|
22
|
+
def artifact_cloud_formation_url(artifact)
|
23
|
+
name_to_url_map = { 'chef_repo' => 'ChefRepoURL',
|
24
|
+
'app' => 'AppArtifactURL',
|
25
|
+
'cookbooks' => 'CookbooksURL' }
|
26
|
+
name_to_url_map[artifact]
|
27
|
+
end
|
28
|
+
|
29
|
+
def artifact_domain(artifact)
|
30
|
+
config['artifacts'][artifact]['domain'] ||= artifact
|
31
|
+
end
|
32
|
+
|
33
|
+
def artifact_bucket_prefix(artifact)
|
34
|
+
config['artifacts'][artifact]['bucket_prefix']
|
18
35
|
end
|
19
36
|
|
20
37
|
def deploy_script
|
21
|
-
|
38
|
+
'/opt/intu/admin/bin/configure.sh'
|
22
39
|
end
|
23
40
|
|
24
41
|
def environments
|
@@ -33,12 +50,13 @@ module SimpleDeploy
|
|
33
50
|
environment(name)['region']
|
34
51
|
end
|
35
52
|
|
36
|
-
def artifact_repository
|
37
|
-
config['artifact_repository']
|
38
|
-
end
|
39
|
-
|
40
53
|
private
|
41
54
|
|
55
|
+
def load_config_file
|
56
|
+
config_file = "#{ENV['HOME']}/.simple_deploy.yml"
|
57
|
+
self.config = YAML::load( File.open( config_file ) )
|
58
|
+
end
|
59
|
+
|
42
60
|
def env_home
|
43
61
|
ENV['HOME']
|
44
62
|
end
|
data/lib/simple_deploy/logger.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/cli'
|
3
|
+
|
4
|
+
module SimpleDeploy
|
5
|
+
class Stack
|
6
|
+
class Deployment
|
7
|
+
def initialize(args)
|
8
|
+
@config = args[:config]
|
9
|
+
@logger = @config.logger
|
10
|
+
@instances = args[:instances]
|
11
|
+
@attributes = args[:attributes]
|
12
|
+
@environment = args[:environment]
|
13
|
+
@ssh_gateway = @attributes['ssh_gateway']
|
14
|
+
@ssh_user = args[:ssh_user]
|
15
|
+
@ssh_key = args[:ssh_key]
|
16
|
+
|
17
|
+
@region = @config.region(@environment)
|
18
|
+
@deploy_script = @config.deploy_script
|
19
|
+
|
20
|
+
create_deployment
|
21
|
+
set_deploy_command
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
@logger.info 'Starting deployment.'
|
26
|
+
@deployment.simpledeploy
|
27
|
+
@logger.info 'Deployment complete.'
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def set_deploy_command
|
33
|
+
cmd = get_artifact_endpoints.any? ? "env " : ""
|
34
|
+
get_artifact_endpoints.each_pair do |k,v|
|
35
|
+
cmd += "#{k}=#{v} "
|
36
|
+
end
|
37
|
+
cmd += @deploy_script
|
38
|
+
|
39
|
+
@logger.info "Executing '#{cmd}.'"
|
40
|
+
@deployment.load :string => "task :simpledeploy do
|
41
|
+
sudo '#{cmd}'
|
42
|
+
end"
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_artifact_endpoints
|
46
|
+
h = {}
|
47
|
+
@config.artifacts.each do |artifact|
|
48
|
+
variable = @config.artifact_deploy_variable artifact
|
49
|
+
bucket_prefix = @config.artifact_bucket_prefix artifact
|
50
|
+
|
51
|
+
artifact = Artifact.new :name => artifact,
|
52
|
+
:id => @attributes[artifact],
|
53
|
+
:region => @region,
|
54
|
+
:config => @config,
|
55
|
+
:bucket_prefix => bucket_prefix
|
56
|
+
h[variable] = artifact.endpoints['s3']
|
57
|
+
end
|
58
|
+
h
|
59
|
+
end
|
60
|
+
|
61
|
+
def ssh_options
|
62
|
+
@logger.info "Setting key to #{@ssh_key}."
|
63
|
+
{
|
64
|
+
:keys => @ssh_key,
|
65
|
+
:paranoid => false
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_deployment
|
70
|
+
@deployment = Capistrano::Configuration.new
|
71
|
+
if @ssh_user
|
72
|
+
@logger.info "Setting user to #{@ssh_user}."
|
73
|
+
@deployment.set :user, @ssh_user
|
74
|
+
end
|
75
|
+
|
76
|
+
if @ssh_gateway
|
77
|
+
@deployment.set :gateway, @ssh_gateway
|
78
|
+
@logger.info "Proxying via gateway #{@ssh_gateway}."
|
79
|
+
else
|
80
|
+
@logger.info "Not using an ssh gateway."
|
81
|
+
end
|
82
|
+
|
83
|
+
@deployment.variables[:ssh_options] = ssh_options
|
84
|
+
|
85
|
+
@instances.each do |i|
|
86
|
+
@logger.info "Adding instance #{i}."
|
87
|
+
@deployment.server i, :instances
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
@@ -2,23 +2,22 @@ module SimpleDeploy
|
|
2
2
|
class StackAttributeFormater
|
3
3
|
|
4
4
|
def initialize(args)
|
5
|
-
@attributes = args[:attributes]
|
6
5
|
@config = args[:config]
|
7
6
|
@environment = args[:environment]
|
8
7
|
@region = @config.region @environment
|
9
8
|
@logger = @config.logger
|
10
9
|
end
|
11
10
|
|
12
|
-
def updated_attributes
|
11
|
+
def updated_attributes(attributes)
|
13
12
|
updates = []
|
14
|
-
|
13
|
+
attributes.each do |attribute|
|
15
14
|
key = attribute.keys.first
|
16
15
|
if artifact_names.include? key
|
17
16
|
updates << cloud_formation_url(attribute)
|
18
17
|
@logger.info "Adding artifact attribute: #{cloud_formation_url(attribute)}"
|
19
18
|
end
|
20
19
|
end
|
21
|
-
|
20
|
+
attributes + updates
|
22
21
|
end
|
23
22
|
|
24
23
|
def artifact_names
|
@@ -30,10 +29,8 @@ module SimpleDeploy
|
|
30
29
|
id = attribute[name]
|
31
30
|
a = @config.artifacts.select { |a| a['name'] == name }.first
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
bucket_prefix = a['bucket_prefix']
|
36
|
-
cloud_formation_url = a['cloud_formation_url']
|
32
|
+
bucket_prefix = @config.artifact_bucket_prefix artifact
|
33
|
+
cloud_formation_url = @config.artifact_cloud_formation_url artifact
|
37
34
|
|
38
35
|
artifact = Artifact.new :name => name,
|
39
36
|
:id => id,
|
@@ -41,7 +38,7 @@ module SimpleDeploy
|
|
41
38
|
:config => @config,
|
42
39
|
:bucket_prefix => bucket_prefix
|
43
40
|
|
44
|
-
{ cloud_formation_url => artifact.endpoints[
|
41
|
+
{ cloud_formation_url => artifact.endpoints['s3'] }
|
45
42
|
end
|
46
43
|
|
47
44
|
end
|
data/lib/simple_deploy/stack.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'stackster'
|
2
|
+
require 'simple_deploy/stack/deployment'
|
2
3
|
require 'simple_deploy/stack/stack_reader'
|
3
4
|
require 'simple_deploy/stack/stack_lister'
|
4
5
|
require 'simple_deploy/stack/stack_attribute_formater'
|
@@ -10,44 +11,62 @@ module SimpleDeploy
|
|
10
11
|
@environment = args[:environment]
|
11
12
|
@name = args[:name]
|
12
13
|
@config = Config.new :logger => args[:logger]
|
13
|
-
|
14
|
-
|
15
|
-
def self.list(args)
|
16
|
-
StackLister.new(:config => args[:config]).all
|
14
|
+
@logger = @config.logger
|
17
15
|
end
|
18
16
|
|
19
17
|
def create(args)
|
20
|
-
|
21
|
-
:config => @config,
|
22
|
-
:environment => @environment)
|
23
|
-
stack.create :attributes => saf.updated_attributes,
|
18
|
+
stack.create :attributes => stack_attribute_formater.updated_attributes(args[:attributes]),
|
24
19
|
:template => args[:template]
|
25
20
|
end
|
26
21
|
|
27
22
|
def update(args)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
23
|
+
stack.update :attributes => stack_attribute_formater.updated_attributes(args[:attributes])
|
24
|
+
end
|
25
|
+
|
26
|
+
# To Do: Abstract deployment into it's own class
|
27
|
+
# Pass in required stack objects for attribut mgmt
|
28
|
+
def deploy(force = false)
|
29
|
+
@logger.info "Checking deployment status."
|
30
|
+
if deployment_in_progress?
|
31
|
+
@logger.info "Deployment in progress."
|
32
|
+
@logger.info "Started by #{attributes['deployment_user']}@#{attributes['deployment_datetime']}."
|
33
|
+
if force
|
34
|
+
clear_deployment_status
|
35
|
+
else
|
36
|
+
@logger.error "Exiting due to existing deployment."
|
37
|
+
@logger.error "Use -f to override."
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
else
|
41
|
+
@logger.info "No other deployments in progress."
|
42
|
+
end
|
43
|
+
set_deployment_in_progress
|
42
44
|
deployment.execute
|
45
|
+
clear_deployment_status
|
46
|
+
end
|
47
|
+
|
48
|
+
def deployment_in_progress?
|
49
|
+
attributes['deployment_in_progress'] == 'true'
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_deployment_in_progress
|
53
|
+
@logger.info "Setting deployment in progress by #{ssh_user}."
|
54
|
+
stack.update :attributes => [ { 'deployment_in_progress' => 'true',
|
55
|
+
'deployment_user' => ssh_user,
|
56
|
+
'deployment_datetime' => Time.now.to_s } ]
|
57
|
+
end
|
58
|
+
|
59
|
+
def clear_deployment_status
|
60
|
+
@logger.info "Clearing deployment status."
|
61
|
+
stack.update :attributes => [ { 'deployment_in_progress' => '' } ]
|
43
62
|
end
|
44
63
|
|
45
64
|
def destroy
|
46
65
|
stack.destroy
|
47
66
|
end
|
48
67
|
|
49
|
-
def events
|
50
|
-
stack.events
|
68
|
+
def events(limit)
|
69
|
+
stack.events limit
|
51
70
|
end
|
52
71
|
|
53
72
|
def outputs
|
@@ -88,7 +107,29 @@ module SimpleDeploy
|
|
88
107
|
@stack ||= Stackster::Stack.new :environment => @environment,
|
89
108
|
:name => @name,
|
90
109
|
:config => @config.environment(@environment),
|
91
|
-
:logger => @
|
110
|
+
:logger => @logger
|
111
|
+
end
|
112
|
+
|
113
|
+
def stack_attribute_formater
|
114
|
+
@saf ||= StackAttributeFormater.new :config => @config,
|
115
|
+
:environment => @environment
|
116
|
+
end
|
117
|
+
|
118
|
+
def deployment
|
119
|
+
@deployment ||= Stack::Deployment.new :config => @config,
|
120
|
+
:environment => @environment,
|
121
|
+
:instances => instances,
|
122
|
+
:attributes => attributes,
|
123
|
+
:ssh_user => ssh_user,
|
124
|
+
:ssh_key => ssh_key
|
125
|
+
end
|
126
|
+
|
127
|
+
def ssh_key
|
128
|
+
ENV['SIMPLE_DEPLOY_SSH_KEY'] ||= "#{ENV['HOME']}/.ssh/id_rsa"
|
129
|
+
end
|
130
|
+
|
131
|
+
def ssh_user
|
132
|
+
ENV['SIMPLE_DEPLOY_SSH_USER'] ||= ENV['USER']
|
92
133
|
end
|
93
134
|
|
94
135
|
end
|
data/lib/simple_deploy.rb
CHANGED
data/simple_deploy.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70101555575840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70101555575840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: capistrano
|
27
|
-
requirement: &
|
27
|
+
requirement: &70101555575240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70101555575240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: stackster
|
38
|
-
requirement: &
|
38
|
+
requirement: &70101555573540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.2.
|
43
|
+
version: 0.2.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70101555573540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: trollop
|
49
|
-
requirement: &
|
49
|
+
requirement: &70101555572840 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70101555572840
|
58
58
|
description: I am designed to deploy artifacts uploaded by Heirloom
|
59
59
|
email:
|
60
60
|
- brett@weav.net
|
@@ -65,6 +65,7 @@ extra_rdoc_files: []
|
|
65
65
|
files:
|
66
66
|
- .gitignore
|
67
67
|
- .rvmrc
|
68
|
+
- CHANGELOG
|
68
69
|
- Gemfile
|
69
70
|
- LICENSE
|
70
71
|
- README.md
|
@@ -75,9 +76,9 @@ files:
|
|
75
76
|
- lib/simple_deploy/cli.rb
|
76
77
|
- lib/simple_deploy/cli/variables.rb
|
77
78
|
- lib/simple_deploy/config.rb
|
78
|
-
- lib/simple_deploy/deployment.rb
|
79
79
|
- lib/simple_deploy/logger.rb
|
80
80
|
- lib/simple_deploy/stack.rb
|
81
|
+
- lib/simple_deploy/stack/deployment.rb
|
81
82
|
- lib/simple_deploy/stack/stack_attribute_formater.rb
|
82
83
|
- lib/simple_deploy/stack/stack_lister.rb
|
83
84
|
- lib/simple_deploy/stack/stack_reader.rb
|
@@ -100,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
101
|
version: '0'
|
101
102
|
segments:
|
102
103
|
- 0
|
103
|
-
hash:
|
104
|
+
hash: 3973264013160818853
|
104
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
106
|
none: false
|
106
107
|
requirements:
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
version: '0'
|
110
111
|
segments:
|
111
112
|
- 0
|
112
|
-
hash:
|
113
|
+
hash: 3973264013160818853
|
113
114
|
requirements: []
|
114
115
|
rubyforge_project: simple_deploy
|
115
116
|
rubygems_version: 1.8.16
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'capistrano'
|
2
|
-
require 'capistrano/cli'
|
3
|
-
|
4
|
-
module SimpleDeploy
|
5
|
-
class Deployment
|
6
|
-
def initialize(args)
|
7
|
-
@config = args[:config]
|
8
|
-
@instances = args[:instances]
|
9
|
-
@ssh_gateway = args[:ssh_gateway]
|
10
|
-
@ssh_user = args[:ssh_user] ||= "#{env_user}"
|
11
|
-
@ssh_key = args[:ssh_key] ||= "#{env_home}/.ssh/id_rsa"
|
12
|
-
@environment = args[:environment]
|
13
|
-
@attributes = args[:attributes]
|
14
|
-
@logger = @config.logger
|
15
|
-
|
16
|
-
@region = @config.region(@environment)
|
17
|
-
@deploy_script = @config.deploy_script
|
18
|
-
|
19
|
-
create_deployment
|
20
|
-
set_deploy_command
|
21
|
-
end
|
22
|
-
|
23
|
-
def execute
|
24
|
-
@logger.info 'Starting deployment.'
|
25
|
-
@deployment.simpledeploy
|
26
|
-
@logger.info 'Deployment complete.'
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def set_deploy_command
|
32
|
-
cmd = get_artifact_endpoints.any? ? "env " : ""
|
33
|
-
get_artifact_endpoints.each_pair do |k,v|
|
34
|
-
cmd += "#{k}=#{v} "
|
35
|
-
end
|
36
|
-
cmd += @deploy_script
|
37
|
-
|
38
|
-
@logger.info "Executing '#{cmd}.'"
|
39
|
-
@deployment.load :string => "task :simpledeploy do
|
40
|
-
sudo '#{cmd}'
|
41
|
-
end"
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_artifact_endpoints
|
45
|
-
h = {}
|
46
|
-
@config.artifacts.each do |a|
|
47
|
-
name = a['name']
|
48
|
-
endpoint = a['endpoint'] ||= 's3'
|
49
|
-
variable = a['variable']
|
50
|
-
bucket_prefix = a['bucket_prefix']
|
51
|
-
|
52
|
-
artifact = Artifact.new :name => name,
|
53
|
-
:id => @attributes[name],
|
54
|
-
:region => @region,
|
55
|
-
:config => @config,
|
56
|
-
:bucket_prefix => bucket_prefix
|
57
|
-
h[variable] = artifact.endpoints[endpoint]
|
58
|
-
end
|
59
|
-
h
|
60
|
-
end
|
61
|
-
|
62
|
-
def ssh_options
|
63
|
-
@logger.info "Setting key to #{@ssh_key}."
|
64
|
-
{
|
65
|
-
:keys => @ssh_key,
|
66
|
-
:paranoid => false
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def create_deployment
|
71
|
-
@deployment = Capistrano::Configuration.new
|
72
|
-
if @ssh_user
|
73
|
-
@logger.info "Setting user to #{@ssh_user}."
|
74
|
-
@deployment.set :user, @ssh_user
|
75
|
-
end
|
76
|
-
|
77
|
-
if @ssh_gateway
|
78
|
-
@deployment.set :gateway, @ssh_gateway
|
79
|
-
@logger.info "Proxying via gateway #{@ssh_gateway}."
|
80
|
-
else
|
81
|
-
@logger.info "Not using an ssh gateway."
|
82
|
-
end
|
83
|
-
|
84
|
-
@deployment.variables[:ssh_options] = ssh_options
|
85
|
-
|
86
|
-
@instances.each do |i|
|
87
|
-
@logger.info "Adding instance #{i}."
|
88
|
-
@deployment.server i, :instances
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def env_home
|
95
|
-
ENV['HOME']
|
96
|
-
end
|
97
|
-
|
98
|
-
def env_user
|
99
|
-
ENV['USER']
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|