eb_deployer 0.4.3 → 0.4.4.beta1
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/lib/eb_deployer/application.rb +1 -1
- data/lib/eb_deployer/component.rb +16 -8
- data/lib/eb_deployer/default_component.rb +2 -2
- data/lib/eb_deployer/deployment_strategy/blue_green.rb +2 -1
- data/lib/eb_deployer/deployment_strategy/inplace_update.rb +1 -1
- data/lib/eb_deployer/eb_environment.rb +21 -10
- data/lib/eb_deployer/environment.rb +6 -6
- data/lib/eb_deployer/version.rb +1 -1
- data/lib/eb_deployer.rb +15 -22
- data/test/blue_green_deploy_test.rb +21 -0
- data/test/multi_components_deploy_test.rb +56 -2
- metadata +6 -9
@@ -6,7 +6,7 @@ module EbDeployer
|
|
6
6
|
@name = name
|
7
7
|
@eb_driver = eb_driver
|
8
8
|
@s3_driver = s3_driver
|
9
|
-
@bucket = bucket
|
9
|
+
@bucket = bucket || @name
|
10
10
|
raise "application name can only contain any combination of uppercase letters, lowercase letters, numbers, dashes (-)" unless @name =~ /^[a-zA-Z0-9.-]+$/
|
11
11
|
end
|
12
12
|
|
@@ -2,28 +2,36 @@ module EbDeployer
|
|
2
2
|
class Component
|
3
3
|
attr_reader :name
|
4
4
|
|
5
|
-
def initialize(name, env,
|
5
|
+
def initialize(name, env, options, eb_driver)
|
6
6
|
@name = name
|
7
7
|
@env = env
|
8
8
|
@eb_driver = eb_driver
|
9
|
-
@
|
10
|
-
@
|
9
|
+
@options = options.dup
|
10
|
+
@component_eb_settings = @options.delete(:option_settings) || []
|
11
|
+
@component_inactive_settings = @options.delete(:inactive_settings) || []
|
12
|
+
strategy_name = @options[:strategy] || @env.strategy_name
|
11
13
|
@strategy = DeploymentStrategy.create(self, strategy_name)
|
12
14
|
end
|
13
15
|
|
14
16
|
def cname_prefix
|
15
|
-
@
|
17
|
+
@options[:cname_prefix] || default_cname_prefix
|
16
18
|
end
|
17
19
|
|
18
|
-
def deploy(version_label, eb_settings)
|
19
|
-
@strategy.deploy(version_label,
|
20
|
+
def deploy(version_label, eb_settings, inactive_settings=[])
|
21
|
+
@strategy.deploy(version_label,
|
22
|
+
eb_settings + @component_eb_settings,
|
23
|
+
inactive_settings + @component_inactive_settings)
|
20
24
|
end
|
21
25
|
|
22
26
|
def new_eb_env(suffix=nil, cname_prefix_overriding=nil)
|
27
|
+
env_name = [@env.name, @name, suffix].compact.join('-')
|
28
|
+
creation_opts = @env.creation_opts.merge(@options)
|
29
|
+
creation_opts = creation_opts.merge(:cname_prefix => cname_prefix_overriding || cname_prefix)
|
23
30
|
EbEnvironment.new(@env.app_name,
|
24
|
-
|
31
|
+
env_name,
|
25
32
|
@eb_driver,
|
26
|
-
|
33
|
+
creation_opts)
|
34
|
+
|
27
35
|
end
|
28
36
|
|
29
37
|
private
|
@@ -12,8 +12,8 @@ module EbDeployer
|
|
12
12
|
end
|
13
13
|
|
14
14
|
|
15
|
-
def deploy(version_label, eb_settings)
|
16
|
-
@strategy.deploy(version_label, eb_settings)
|
15
|
+
def deploy(version_label, eb_settings, inactive_settings=[])
|
16
|
+
@strategy.deploy(version_label, eb_settings, inactive_settings)
|
17
17
|
end
|
18
18
|
|
19
19
|
def new_eb_env(suffix=nil, cname_prefix_overriding=nil)
|
@@ -5,7 +5,7 @@ module EbDeployer
|
|
5
5
|
@env = env
|
6
6
|
end
|
7
7
|
|
8
|
-
def deploy(version_label, env_settings)
|
8
|
+
def deploy(version_label, env_settings, inactive_settings=[])
|
9
9
|
if !ebenvs.any?(&method(:active_ebenv?))
|
10
10
|
ebenv('a', @env.cname_prefix).
|
11
11
|
deploy(version_label, env_settings)
|
@@ -17,6 +17,7 @@ module EbDeployer
|
|
17
17
|
|
18
18
|
inactive_ebenv.deploy(version_label, env_settings)
|
19
19
|
active_ebenv.swap_cname_with(inactive_ebenv)
|
20
|
+
active_ebenv.apply_settings(inactive_settings) unless inactive_settings.empty?
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -18,11 +18,22 @@ module EbDeployer
|
|
18
18
|
|
19
19
|
def deploy(version_label, settings={})
|
20
20
|
terminate if @creation_opts[:phoenix_mode]
|
21
|
-
|
21
|
+
|
22
|
+
if @bs.environment_exists?(@app, @name)
|
23
|
+
update_eb_env(settings, version_label)
|
24
|
+
else
|
25
|
+
create_eb_env(settings, version_label)
|
26
|
+
end
|
27
|
+
|
22
28
|
smoke_test
|
23
29
|
wait_for_env_become_healthy
|
24
30
|
end
|
25
31
|
|
32
|
+
def apply_settings(settings)
|
33
|
+
raise "Env #{self.name} not exists for applying settings" unless @bs.environment_exists?(@app, @name)
|
34
|
+
update_eb_env(settings)
|
35
|
+
end
|
36
|
+
|
26
37
|
def cname_prefix
|
27
38
|
@bs.environment_cname_prefix(@app, @name)
|
28
39
|
end
|
@@ -46,15 +57,15 @@ module EbDeployer
|
|
46
57
|
|
47
58
|
private
|
48
59
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
60
|
+
def create_eb_env(settings, version_label)
|
61
|
+
with_polling_events(/Successfully launched environment/i) do
|
62
|
+
@bs.create_environment(@app, @name, @creation_opts[:solution_stack], @creation_opts[:cname_prefix], version_label, @creation_opts[:tier], settings)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_eb_env(settings, version_label=nil)
|
67
|
+
with_polling_events(/Environment update completed successfully/i) do
|
68
|
+
@bs.update_environment(@app, @name, version_label, @creation_opts[:tier], settings)
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module EbDeployer
|
2
2
|
class Environment
|
3
3
|
include Utils
|
4
|
+
attr_accessor :creation_opts, :strategy_name
|
5
|
+
|
6
|
+
attr_writer :resource_stacks, :settings, :inactive_settings, :components, :component_under_deploy
|
4
7
|
|
5
|
-
attr_writer :resource_stacks, :settings, :creation_opts, :components, :component_under_deploy, :strategy_name
|
6
8
|
attr_reader :name
|
7
9
|
|
8
10
|
def initialize(app, name, eb_driver, &block)
|
@@ -11,6 +13,7 @@ module EbDeployer
|
|
11
13
|
@eb_driver = eb_driver
|
12
14
|
@creation_opts = {}
|
13
15
|
@settings = []
|
16
|
+
@inactive_settings = []
|
14
17
|
@strategy_name = :blue_green
|
15
18
|
yield(self) if block_given?
|
16
19
|
unless @components
|
@@ -25,7 +28,7 @@ module EbDeployer
|
|
25
28
|
def deploy(version_label)
|
26
29
|
resource_settings = @resource_stacks.provision(resource_stack_name)
|
27
30
|
components_to_deploy.each do |component|
|
28
|
-
component.deploy(version_label, @settings + resource_settings)
|
31
|
+
component.deploy(version_label, @settings + resource_settings, @inactive_settings)
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
@@ -33,10 +36,7 @@ module EbDeployer
|
|
33
36
|
return unless components_attrs
|
34
37
|
@components = components_attrs.map do |attrs|
|
35
38
|
attrs = symbolize_keys(attrs)
|
36
|
-
|
37
|
-
eb_settings = attrs.delete(:option_settings) || []
|
38
|
-
strategy_name = attrs[:strategy] || @strategy_name
|
39
|
-
Component.new(name, self, @creation_opts.merge(attrs), eb_settings, strategy_name, @eb_driver)
|
39
|
+
Component.new(attrs.delete(:name), self, attrs, @eb_driver)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
data/lib/eb_deployer/version.rb
CHANGED
data/lib/eb_deployer.rb
CHANGED
@@ -175,32 +175,25 @@ module EbDeployer
|
|
175
175
|
bs = opts[:bs_driver] || AWSDriver::Beanstalk.new
|
176
176
|
s3 = opts[:s3_driver] || AWSDriver::S3Driver.new
|
177
177
|
cf = opts[:cf_driver] || AWSDriver::CloudFormationDriver.new
|
178
|
-
|
179
|
-
app = opts[:application]
|
180
|
-
env_name = opts[:environment]
|
178
|
+
app_name = opts[:application]
|
181
179
|
version_prefix = opts[:version_prefix].to_s.strip
|
182
180
|
version_label = "#{version_prefix}#{opts[:version_label].to_s.strip}"
|
183
|
-
cname = opts[:cname]
|
184
|
-
eb_settings = opts[:option_settings] || opts[:settings] || []
|
185
|
-
cname_prefix = opts[:cname_prefix]
|
186
|
-
smoke_test = opts[:smoke_test] || Proc.new {}
|
187
|
-
phoenix_mode = opts[:phoenix_mode]
|
188
|
-
bucket = opts[:package_bucket] || app
|
189
|
-
skip_resource = opts[:skip_resource_stack_update]
|
190
|
-
keep_latest = opts[:keep_latest].to_i || 0
|
191
|
-
app_tier = opts[:tier] || 'WebServer'
|
192
181
|
|
193
|
-
|
194
|
-
|
195
|
-
|
182
|
+
application = Application.new(app_name, bs, s3, opts[:package_bucket])
|
183
|
+
resource_stacks = ResourceStacks.new(opts[:resources],
|
184
|
+
cf,
|
185
|
+
opts[:skip_resource_stack_update])
|
186
|
+
|
187
|
+
environment = Environment.new(application, opts[:environment], bs) do |env|
|
196
188
|
env.resource_stacks = resource_stacks
|
197
|
-
env.settings =
|
189
|
+
env.settings = opts[:option_settings] || opts[:settings] || []
|
190
|
+
env.inactive_settings = opts[:inactve_settings] || []
|
198
191
|
env.creation_opts = {
|
199
|
-
:solution_stack =>
|
200
|
-
:cname_prefix =>
|
201
|
-
:smoke_test => smoke_test,
|
202
|
-
:phoenix_mode => phoenix_mode,
|
203
|
-
:tier =>
|
192
|
+
:solution_stack => opts[:solution_stack_name] || "64bit Amazon Linux 2013.09 running Tomcat 7 Java 7",
|
193
|
+
:cname_prefix => opts[:cname_prefix],
|
194
|
+
:smoke_test => opts[:smoke_test] || Proc.new {},
|
195
|
+
:phoenix_mode => opts[:phoenix_mode],
|
196
|
+
:tier => opts[:tier] || 'WebServer'
|
204
197
|
}
|
205
198
|
env.strategy_name = opts[:strategy] || :blue_green
|
206
199
|
env.components = opts[:components]
|
@@ -209,7 +202,7 @@ module EbDeployer
|
|
209
202
|
|
210
203
|
application.create_version(version_label, opts[:package])
|
211
204
|
environment.deploy(version_label)
|
212
|
-
application.clean_versions(version_prefix, keep_latest)
|
205
|
+
application.clean_versions(version_prefix, opts[:keep_latest].to_i || 0)
|
213
206
|
end
|
214
207
|
|
215
208
|
def self.destroy(opts)
|
@@ -64,6 +64,27 @@ class BlueGreenDeployTest < DeployTest
|
|
64
64
|
assert !@eb.environment_exists?('simple', t('production-b', 'simple'))
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_can_have_inactive_settings_which_will_be_applied_to_inactive_env
|
68
|
+
settings = {:option_settings =>
|
69
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
70
|
+
:option_name => 'MinSize',
|
71
|
+
:value => 10}],
|
72
|
+
:inactve_settings =>
|
73
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
74
|
+
:option_name => 'MinSize',
|
75
|
+
:value => 1}]}
|
76
|
+
|
77
|
+
do_deploy(42, settings)
|
78
|
+
assert_equal 10, @eb.environment_settings('simple', t('production-a', 'simple')).last[:value]
|
79
|
+
|
80
|
+
do_deploy(43, settings)
|
81
|
+
assert_equal 1, @eb.environment_settings('simple', t('production-a', 'simple')).last[:value]
|
82
|
+
assert_equal 10, @eb.environment_settings('simple', t('production-b', 'simple')).last[:value]
|
83
|
+
|
84
|
+
do_deploy(44, settings)
|
85
|
+
assert_equal 10, @eb.environment_settings('simple', t('production-a', 'simple')).last[:value]
|
86
|
+
assert_equal 1, @eb.environment_settings('simple', t('production-b', 'simple')).last[:value]
|
87
|
+
end
|
67
88
|
|
68
89
|
private
|
69
90
|
|
@@ -86,6 +86,60 @@ class MultiComponentsDeployTest < DeployTest
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
|
90
|
+
def test_can_have_inactive_settings_which_will_be_applied_to_inactive_env
|
91
|
+
settings = {:inactve_settings =>
|
92
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
93
|
+
:option_name => 'MinSize',
|
94
|
+
:value => 1}],
|
95
|
+
:components =>
|
96
|
+
[{:name => 'web',
|
97
|
+
:option_settings =>
|
98
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
99
|
+
:option_name => 'MinSize',
|
100
|
+
:value => 10}]}]}
|
101
|
+
|
102
|
+
do_bg_deploy(settings)
|
103
|
+
assert_equal 10, @eb.environment_settings('simple', t('prod-web-a', 'simple')).last[:value]
|
104
|
+
|
105
|
+
do_bg_deploy(settings)
|
106
|
+
assert_equal 1, @eb.environment_settings('simple', t('prod-web-a', 'simple')).last[:value]
|
107
|
+
assert_equal 10, @eb.environment_settings('simple', t('prod-web-b', 'simple')).last[:value]
|
108
|
+
|
109
|
+
do_bg_deploy(settings)
|
110
|
+
assert_equal 10, @eb.environment_settings('simple', t('prod-web-a', 'simple')).last[:value]
|
111
|
+
assert_equal 1, @eb.environment_settings('simple', t('prod-web-b', 'simple')).last[:value]
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_can_provide_inactive_settings_at_component_level
|
115
|
+
settings = {:option_settings =>
|
116
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
117
|
+
:option_name => 'MinSize',
|
118
|
+
:value => 10}],
|
119
|
+
:components =>
|
120
|
+
[{:name => 'web',
|
121
|
+
:inactive_settings =>
|
122
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
123
|
+
:option_name => 'MinSize',
|
124
|
+
:value => 2}]},
|
125
|
+
{:name => 'api',
|
126
|
+
:inactive_settings =>
|
127
|
+
[{:namespace => 'aws:autoscaling:launchconfiguration',
|
128
|
+
:option_name => 'MinSize',
|
129
|
+
:value => 1}]}]}
|
130
|
+
|
131
|
+
do_bg_deploy(settings)
|
132
|
+
assert_equal 10, @eb.environment_settings('simple', t('prod-web-a', 'simple')).last[:value]
|
133
|
+
assert_equal 10, @eb.environment_settings('simple', t('prod-api-a', 'simple')).last[:value]
|
134
|
+
|
135
|
+
do_bg_deploy(settings)
|
136
|
+
assert_equal 2, @eb.environment_settings('simple', t('prod-web-a', 'simple')).last[:value]
|
137
|
+
assert_equal 1, @eb.environment_settings('simple', t('prod-api-a', 'simple')).last[:value]
|
138
|
+
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
|
89
143
|
private
|
90
144
|
def do_deploy(options={})
|
91
145
|
deploy({:application => 'simple',
|
@@ -96,8 +150,8 @@ class MultiComponentsDeployTest < DeployTest
|
|
96
150
|
}.merge(options))
|
97
151
|
end
|
98
152
|
|
99
|
-
def do_bg_deploy
|
100
|
-
do_deploy(:strategy => 'blue-green')
|
153
|
+
def do_bg_deploy(options={})
|
154
|
+
do_deploy(options.merge(:strategy => 'blue-green'))
|
101
155
|
end
|
102
156
|
|
103
157
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eb_deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.4.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- wpc
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-04-
|
13
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -100,16 +100,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: -3919206102584953586
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- - ! '
|
107
|
+
- - ! '>'
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
hash: 567704794056721741
|
109
|
+
version: 1.3.1
|
113
110
|
requirements: []
|
114
111
|
rubyforge_project:
|
115
112
|
rubygems_version: 1.8.29
|