simple_deploy 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -19
- data/lib/simple_deploy/cli/variables.rb +5 -2
- data/lib/simple_deploy/config.rb +17 -3
- data/lib/simple_deploy/deployment.rb +16 -3
- data/lib/simple_deploy/logger.rb +21 -0
- data/lib/simple_deploy/stack/stack_attribute_formater.rb +48 -0
- data/lib/simple_deploy/stack.rb +11 -3
- data/lib/simple_deploy/version.rb +1 -1
- data/lib/simple_deploy.rb +1 -0
- metadata +14 -12
data/README.md
CHANGED
@@ -13,32 +13,27 @@ Create a file **~/.simple_deploy.yml** and include within it:
|
|
13
13
|
|
14
14
|
```
|
15
15
|
deploy:
|
16
|
-
|
17
|
-
user: ec2-user
|
16
|
+
gateway: GATEWAY_TO_YOUR_VPC
|
18
17
|
artifacts:
|
18
|
+
- name: live_community_chef_repo
|
19
|
+
bucket_prefix: intu-lc
|
20
|
+
variable: CHEF_REPO_URL
|
21
|
+
cloud_formation_url: ChefRepoURL
|
22
|
+
- name: live_community
|
23
|
+
bucket_prefix: intu-lc
|
24
|
+
variable: APP_URL
|
25
|
+
cloud_formation_url: AppArtifactURL
|
19
26
|
- name: cookbooks
|
20
|
-
bucket_prefix: artifacts
|
21
|
-
endpoint: http
|
27
|
+
bucket_prefix: intu-artifacts
|
22
28
|
variable: COOKBOOKS_URL
|
23
|
-
|
29
|
+
cloud_formation_url: CookbooksURL
|
30
|
+
script: /opt/intu/admin/bin/configure.sh
|
24
31
|
|
25
32
|
environments:
|
26
|
-
|
33
|
+
preprod_shared_us_west_1:
|
27
34
|
access_key: XXX
|
28
|
-
secret_key:
|
35
|
+
secret_key: yyy
|
29
36
|
region: us-west-1
|
30
|
-
prod_us_west_1:
|
31
|
-
access_key: YYY
|
32
|
-
secret_key: YYY
|
33
|
-
region: us-west-1
|
34
|
-
preprod_us_east_1:
|
35
|
-
access_key: XXX
|
36
|
-
secret_key: XXX
|
37
|
-
region: us-east-1
|
38
|
-
prod_us_east_1:
|
39
|
-
access_key: YYY
|
40
|
-
secret_key: YYY
|
41
|
-
region: us-east-1
|
42
37
|
```
|
43
38
|
|
44
39
|
Commands
|
@@ -2,9 +2,12 @@ module SimpleDeploy
|
|
2
2
|
module CLI
|
3
3
|
def self.attributes
|
4
4
|
attrs = []
|
5
|
+
puts "Read the following attributes:"
|
5
6
|
read_attributes.each do |attribs|
|
6
|
-
|
7
|
-
|
7
|
+
key = attribs.split('=').first.gsub(/\s+/, "")
|
8
|
+
value = attribs.gsub(/^.+?=/, '')
|
9
|
+
puts "#{key} : #{value}"
|
10
|
+
attrs << { key => value }
|
8
11
|
end
|
9
12
|
attrs
|
10
13
|
end
|
data/lib/simple_deploy/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module SimpleDeploy
|
2
2
|
class Config
|
3
3
|
|
4
|
-
attr_accessor :config
|
4
|
+
attr_accessor :config, :logger
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
load_config_file
|
@@ -17,11 +17,15 @@ module SimpleDeploy
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def keys
|
20
|
-
config['deploy']['keys']
|
20
|
+
config['deploy']['keys'] ||= "#{env_home}/.ssh/id_rsa"
|
21
|
+
end
|
22
|
+
|
23
|
+
def gateway
|
24
|
+
config['deploy']['gateway']
|
21
25
|
end
|
22
26
|
|
23
27
|
def user
|
24
|
-
config['deploy']['user']
|
28
|
+
config['deploy']['user'] ||= "#{env_user}"
|
25
29
|
end
|
26
30
|
|
27
31
|
def deploy_script
|
@@ -44,5 +48,15 @@ module SimpleDeploy
|
|
44
48
|
config['artifact_repository']
|
45
49
|
end
|
46
50
|
|
51
|
+
private
|
52
|
+
|
53
|
+
def env_home
|
54
|
+
ENV['HOME']
|
55
|
+
end
|
56
|
+
|
57
|
+
def env_user
|
58
|
+
ENV['USER']
|
59
|
+
end
|
60
|
+
|
47
61
|
end
|
48
62
|
end
|
@@ -8,6 +8,7 @@ module SimpleDeploy
|
|
8
8
|
@instances = args[:instances]
|
9
9
|
@environment = args[:environment]
|
10
10
|
@attributes = args[:attributes]
|
11
|
+
@logger = @config.logger
|
11
12
|
|
12
13
|
@region = @config.region(@environment)
|
13
14
|
@deploy_script = @config.deploy_script
|
@@ -17,6 +18,7 @@ module SimpleDeploy
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def execute
|
21
|
+
@logger.info 'Starting Deployment.'
|
20
22
|
@deployment.simpledeploy
|
21
23
|
end
|
22
24
|
|
@@ -29,6 +31,7 @@ module SimpleDeploy
|
|
29
31
|
end
|
30
32
|
cmd += @deploy_script
|
31
33
|
|
34
|
+
@logger.info "Executing '#{cmd}.'"
|
32
35
|
@deployment.load :string => "task :simpledeploy do
|
33
36
|
sudo '#{cmd}'
|
34
37
|
end"
|
@@ -38,7 +41,7 @@ module SimpleDeploy
|
|
38
41
|
h = {}
|
39
42
|
@config.artifacts.each do |a|
|
40
43
|
name = a['name']
|
41
|
-
endpoint = a['endpoint']
|
44
|
+
endpoint = a['endpoint'] ||= 's3'
|
42
45
|
variable = a['variable']
|
43
46
|
bucket_prefix = a['bucket_prefix']
|
44
47
|
|
@@ -53,6 +56,7 @@ module SimpleDeploy
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def ssh_options
|
59
|
+
@logger.info "Setting key to #{@config.keys}." if @config.keys
|
56
60
|
{
|
57
61
|
:keys => @config.keys,
|
58
62
|
:paranoid => false
|
@@ -61,9 +65,18 @@ module SimpleDeploy
|
|
61
65
|
|
62
66
|
def create_deployment
|
63
67
|
@deployment = Capistrano::Configuration.new
|
64
|
-
|
68
|
+
if @config.user
|
69
|
+
@logger.info "Setting user to #{@config.user}."
|
70
|
+
@deployment.set :user, @config.user
|
71
|
+
end
|
72
|
+
@deployment.set :gateway, @config.gateway if @config.gateway
|
65
73
|
@deployment.variables[:ssh_options] = ssh_options
|
66
|
-
@
|
74
|
+
@logger.info "Proxying via gateway #{@config.gateway}."
|
75
|
+
|
76
|
+
@instances.each do |i|
|
77
|
+
@logger.info "Adding instance #{i}."
|
78
|
+
@deployment.server i, :instances
|
79
|
+
end
|
67
80
|
end
|
68
81
|
end
|
69
82
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SimpleDeploy
|
2
|
+
class SimpleDeployLogger
|
3
|
+
|
4
|
+
def initialize(args = {})
|
5
|
+
@logger = args[:logger] ||= Logger.new(STDOUT)
|
6
|
+
|
7
|
+
unless args[:logger]
|
8
|
+
@logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
9
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
10
|
+
"#{datetime}: #{msg}\n"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
@logger
|
15
|
+
end
|
16
|
+
|
17
|
+
def info(msg)
|
18
|
+
@logger.info msg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module SimpleDeploy
|
2
|
+
class StackAttributeFormater
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@attributes = args[:attributes]
|
6
|
+
@config = args[:config]
|
7
|
+
@environment = args[:environment]
|
8
|
+
@region = @config.region @environment
|
9
|
+
@logger = @config.logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def updated_attributes
|
13
|
+
updates = []
|
14
|
+
@attributes.each do |attribute|
|
15
|
+
key = attribute.keys.first
|
16
|
+
if artifact_names.include? key
|
17
|
+
updates << cloud_formation_url(attribute)
|
18
|
+
@logger.info "Adding artifact attribute: #{cloud_formation_url(attribute)}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@attributes + updates
|
22
|
+
end
|
23
|
+
|
24
|
+
def artifact_names
|
25
|
+
@config.artifacts.map {|i| i['name']}
|
26
|
+
end
|
27
|
+
|
28
|
+
def cloud_formation_url attribute
|
29
|
+
name = attribute.keys.first
|
30
|
+
id = attribute[name]
|
31
|
+
a = @config.artifacts.select { |a| a['name'] == name }.first
|
32
|
+
|
33
|
+
endpoint = a['endpoint'] ||= 's3'
|
34
|
+
variable = a['variable']
|
35
|
+
bucket_prefix = a['bucket_prefix']
|
36
|
+
cloud_formation_url = a['cloud_formation_url']
|
37
|
+
|
38
|
+
artifact = Artifact.new :name => name,
|
39
|
+
:id => id,
|
40
|
+
:region => @region,
|
41
|
+
:config => @config,
|
42
|
+
:bucket_prefix => bucket_prefix
|
43
|
+
|
44
|
+
{ cloud_formation_url => artifact.endpoints[endpoint] }
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/simple_deploy/stack.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'stackster'
|
2
2
|
require 'simple_deploy/stack/stack_reader'
|
3
3
|
require 'simple_deploy/stack/stack_lister'
|
4
|
+
require 'simple_deploy/stack/stack_attribute_formater'
|
4
5
|
|
5
6
|
module SimpleDeploy
|
6
7
|
class Stack
|
@@ -9,6 +10,7 @@ module SimpleDeploy
|
|
9
10
|
@environment = args[:environment]
|
10
11
|
@name = args[:name]
|
11
12
|
@config = Config.new
|
13
|
+
@config.logger = SimpleDeployLogger.new
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.list(args)
|
@@ -16,12 +18,18 @@ module SimpleDeploy
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def create(args)
|
19
|
-
|
21
|
+
saf = StackAttributeFormater.new(:attributes => args[:attributes],
|
22
|
+
:config => @config,
|
23
|
+
:environment => @environment)
|
24
|
+
stack.create :attributes => saf.updated_attributes,
|
20
25
|
:template => args[:template]
|
21
26
|
end
|
22
27
|
|
23
28
|
def update(args)
|
24
|
-
|
29
|
+
saf = StackAttributeFormater.new(:attributes => args[:attributes],
|
30
|
+
:config => @config,
|
31
|
+
:environment => @environment)
|
32
|
+
stack.update :attributes => saf.updated_attributes
|
25
33
|
end
|
26
34
|
|
27
35
|
def deploy
|
@@ -49,7 +57,7 @@ module SimpleDeploy
|
|
49
57
|
end
|
50
58
|
|
51
59
|
def instances
|
52
|
-
stack.
|
60
|
+
stack.instances_private_ip_addresses
|
53
61
|
end
|
54
62
|
|
55
63
|
def status
|
data/lib/simple_deploy.rb
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.2.
|
4
|
+
version: 0.2.2
|
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-06-
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70197676003120 !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: *70197676003120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: capistrano
|
27
|
-
requirement: &
|
27
|
+
requirement: &70197676002640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70197676002640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: stackster
|
38
|
-
requirement: &
|
38
|
+
requirement: &70197676002080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70197676002080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: trollop
|
49
|
-
requirement: &
|
49
|
+
requirement: &70197676001540 !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: *70197676001540
|
58
58
|
description: I am designed to deploy artifacts uploaded by Heirloom
|
59
59
|
email:
|
60
60
|
- brett@weav.net
|
@@ -76,7 +76,9 @@ files:
|
|
76
76
|
- lib/simple_deploy/cli/variables.rb
|
77
77
|
- lib/simple_deploy/config.rb
|
78
78
|
- lib/simple_deploy/deployment.rb
|
79
|
+
- lib/simple_deploy/logger.rb
|
79
80
|
- lib/simple_deploy/stack.rb
|
81
|
+
- lib/simple_deploy/stack/stack_attribute_formater.rb
|
80
82
|
- lib/simple_deploy/stack/stack_lister.rb
|
81
83
|
- lib/simple_deploy/stack/stack_reader.rb
|
82
84
|
- lib/simple_deploy/version.rb
|
@@ -98,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
100
|
version: '0'
|
99
101
|
segments:
|
100
102
|
- 0
|
101
|
-
hash:
|
103
|
+
hash: 3779767158902072775
|
102
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
105
|
none: false
|
104
106
|
requirements:
|
@@ -107,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
version: '0'
|
108
110
|
segments:
|
109
111
|
- 0
|
110
|
-
hash:
|
112
|
+
hash: 3779767158902072775
|
111
113
|
requirements: []
|
112
114
|
rubyforge_project: simple_deploy
|
113
115
|
rubygems_version: 1.8.16
|