automan 2.3.5 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -5
- data/automan.gemspec +3 -3
- data/lib/automan.rb +0 -1
- data/lib/automan/base.rb +3 -7
- data/lib/automan/beanstalk/deployer.rb +1 -1
- data/lib/automan/beanstalk/package.rb +1 -1
- data/lib/automan/beanstalk/router.rb +1 -1
- data/lib/automan/cli/snapper.rb +23 -3
- data/lib/automan/cli/stacker.rb +0 -19
- data/lib/automan/cloudformation/launcher.rb +3 -6
- data/lib/automan/cloudformation/replacer.rb +1 -1
- data/lib/automan/cloudformation/terminator.rb +1 -1
- data/lib/automan/ec2/image.rb +3 -3
- data/lib/automan/mixins/aws_caller.rb +7 -21
- data/lib/automan/rds/snapshot.rb +25 -35
- data/lib/automan/s3/downloader.rb +1 -10
- data/lib/automan/version.rb +1 -1
- data/spec/beanstalk/application_spec.rb +17 -17
- data/spec/beanstalk/configuration_spec.rb +24 -24
- data/spec/beanstalk/deployer_spec.rb +65 -65
- data/spec/beanstalk/router_spec.rb +19 -18
- data/spec/beanstalk/terminator_spec.rb +16 -16
- data/spec/beanstalk/uploader_spec.rb +13 -13
- data/spec/beanstalk/version_spec.rb +10 -8
- data/spec/cloudformation/launcher_spec.rb +65 -63
- data/spec/cloudformation/replacer_spec.rb +10 -10
- data/spec/cloudformation/terminator_spec.rb +23 -23
- data/spec/cloudformation/uploader_spec.rb +13 -13
- data/spec/ec2/image_spec.rb +55 -55
- data/spec/ec2/instance_spec.rb +17 -17
- data/spec/mixins/aws_caller_spec.rb +9 -9
- data/spec/mixins/utils_spec.rb +28 -27
- data/spec/rds/snapshot_spec.rb +46 -44
- metadata +9 -22
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -5
- data/lib/automan/elasticache/router.rb +0 -79
- data/spec/elasticache/router_spec.rb +0 -29
- data/templates/stacker/.env.example +0 -14
- data/templates/stacker/.gitignore +0 -2
- data/templates/stacker/.ruby-gemset.tt +0 -1
- data/templates/stacker/.ruby-version +0 -1
- data/templates/stacker/Gemfile +0 -4
- data/templates/stacker/bin/%app_name%.tt +0 -62
- data/templates/stacker/bin/launch_%app_name%.sh.tt +0 -12
data/spec/rds/snapshot_spec.rb
CHANGED
@@ -4,35 +4,35 @@ require 'logger'
|
|
4
4
|
ENV['MAX_SNAPSHOTS'] = "50"
|
5
5
|
|
6
6
|
describe Automan::RDS::Snapshot do
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
7
|
+
it { should respond_to :rds }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :delete }
|
10
|
+
it { should respond_to :prune }
|
11
|
+
it { should respond_to :latest }
|
12
|
+
it { should respond_to :default_snapshot_name }
|
13
13
|
|
14
14
|
describe '#default_snapshot_name' do
|
15
|
-
subject() do
|
15
|
+
subject(:s) do
|
16
16
|
AWS.stub!
|
17
17
|
s = Automan::RDS::Snapshot.new
|
18
18
|
s.logger = Logger.new('/dev/null')
|
19
|
-
|
19
|
+
s.stub(:db_environment).and_return('dev1')
|
20
20
|
s
|
21
21
|
end
|
22
22
|
|
23
23
|
it "never returns nil" do
|
24
|
-
|
24
|
+
s.default_snapshot_name('somedb').should_not be_nil
|
25
25
|
end
|
26
26
|
|
27
|
-
it "returns environment dash
|
28
|
-
name =
|
29
|
-
|
27
|
+
it "returns environment dash iso8601 string" do
|
28
|
+
name = s.default_snapshot_name('somedb')
|
29
|
+
name.should match /^dev1-(\d{4})-(\d{2})-(\d{2})T(\d{2})-(\d{2})-(\d{2})[+-](\d{2})-(\d{2})/
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#create' do
|
35
|
-
subject() do
|
35
|
+
subject(:s) do
|
36
36
|
AWS.stub!
|
37
37
|
s = Automan::RDS::Snapshot.new
|
38
38
|
s.logger = Logger.new('/dev/null')
|
@@ -40,56 +40,56 @@ describe Automan::RDS::Snapshot do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "raises error if could not find database" do
|
43
|
-
|
43
|
+
s.stub(:find_db).and_return(nil)
|
44
44
|
expect {
|
45
|
-
|
45
|
+
s.create
|
46
46
|
}.to raise_error Automan::RDS::DatabaseDoesNotExistError
|
47
47
|
end
|
48
48
|
|
49
49
|
it "raises error if RDS says database does not exist" do
|
50
50
|
db = double(:db)
|
51
|
-
|
52
|
-
|
51
|
+
db.stub(:exists?).and_return(false)
|
52
|
+
s.stub(:find_db).and_return(db)
|
53
53
|
|
54
54
|
expect {
|
55
|
-
|
55
|
+
s.create
|
56
56
|
}.to raise_error Automan::RDS::DatabaseDoesNotExistError
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#tagged_can_prune?' do
|
62
|
-
subject() do
|
62
|
+
subject(:s) do
|
63
63
|
AWS.stub!
|
64
64
|
s = Automan::RDS::Snapshot.new
|
65
65
|
s.logger = Logger.new('/dev/null')
|
66
|
-
|
66
|
+
s.stub(:snapshot_arn)
|
67
67
|
s
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'returns true if snapshot is tagged with CanPrune=yes' do
|
71
|
-
|
72
|
-
|
71
|
+
s.stub(:tags).and_return( {'CanPrune' => 'yes'} )
|
72
|
+
s.tagged_can_prune?( double() ).should be_true
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns false if snapshot is missing CanPrune tag' do
|
76
|
-
|
77
|
-
|
76
|
+
s.stub(:tags).and_return( {} )
|
77
|
+
s.tagged_can_prune?( double() ).should be_false
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'returns false if snapshot is tagged with CanPrune=nil' do
|
81
|
-
|
82
|
-
|
81
|
+
s.stub(:tags).and_return( {'CanPrune' => nil} )
|
82
|
+
s.tagged_can_prune?( double() ).should be_false
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'returns false if snapshot is tagged with CanPrune=foo' do
|
86
|
-
|
87
|
-
|
86
|
+
s.stub(:tags).and_return( {'CanPrune' => 'foo'} )
|
87
|
+
s.tagged_can_prune?( double() ).should be_false
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe '#available?' do
|
92
|
-
subject() do
|
92
|
+
subject(:s) do
|
93
93
|
AWS.stub!
|
94
94
|
s = Automan::RDS::Snapshot.new
|
95
95
|
s.logger = Logger.new('/dev/null')
|
@@ -97,19 +97,21 @@ describe Automan::RDS::Snapshot do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'returns true if status is "available"' do
|
100
|
-
snap = double(
|
101
|
-
|
100
|
+
snap = double(:snap)
|
101
|
+
snap.stub(:status).and_return('available')
|
102
|
+
s.available?(snap).should be_true
|
102
103
|
end
|
103
104
|
|
104
105
|
it 'returns false if status is foo' do
|
105
|
-
snap = double(
|
106
|
-
|
106
|
+
snap = double(:snap)
|
107
|
+
snap.stub(:status).and_return('foo')
|
108
|
+
s.available?(snap).should be_false
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
110
112
|
describe '#manual?' do
|
111
113
|
let(:snap) { double }
|
112
|
-
subject() do
|
114
|
+
subject(:s) do
|
113
115
|
AWS.stub!
|
114
116
|
s = Automan::RDS::Snapshot.new
|
115
117
|
s.logger = Logger.new('/dev/null')
|
@@ -117,34 +119,34 @@ describe Automan::RDS::Snapshot do
|
|
117
119
|
end
|
118
120
|
|
119
121
|
it 'returns true if type is "manual"' do
|
120
|
-
|
121
|
-
|
122
|
+
snap.stub(:snapshot_type).and_return('manual')
|
123
|
+
s.manual?(snap).should be_true
|
122
124
|
end
|
123
125
|
|
124
126
|
it 'returns false if type is foo' do
|
125
|
-
|
126
|
-
|
127
|
+
snap.stub(:snapshot_type).and_return('foo')
|
128
|
+
s.manual?(snap).should be_false
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
130
132
|
describe '#prunable_snapshots' do
|
131
133
|
let(:snap) { double }
|
132
|
-
subject() do
|
134
|
+
subject(:s) do
|
133
135
|
AWS.stub!
|
134
136
|
s = Automan::RDS::Snapshot.new
|
135
137
|
s.logger = Logger.new('/dev/null')
|
136
|
-
|
138
|
+
s.stub(:get_all_snapshots).and_return( [ snap ] )
|
137
139
|
s
|
138
140
|
end
|
139
141
|
|
140
142
|
it 'includes snapshots which can be pruned' do
|
141
|
-
|
142
|
-
|
143
|
+
s.stub(:can_prune?).and_return(true)
|
144
|
+
s.prunable_snapshots.should include(snap)
|
143
145
|
end
|
144
146
|
|
145
147
|
it 'excludes snapshots which should not be pruned' do
|
146
|
-
|
147
|
-
|
148
|
+
s.stub(:can_prune?).and_return(false)
|
149
|
+
s.prunable_snapshots.should_not include(snap)
|
148
150
|
end
|
149
151
|
end
|
150
152
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Chalfant
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,42 +45,42 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.12.2
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.12.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec-mocks
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 2.12.2
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.12.2
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec-expectations
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 2.12.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 2.12.1
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: aws-sdk
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,9 +166,6 @@ extensions: []
|
|
166
166
|
extra_rdoc_files: []
|
167
167
|
files:
|
168
168
|
- ".gitignore"
|
169
|
-
- ".ruby-gemset"
|
170
|
-
- ".ruby-version"
|
171
|
-
- ".travis.yml"
|
172
169
|
- Gemfile
|
173
170
|
- LICENSE.txt
|
174
171
|
- README.md
|
@@ -207,7 +204,6 @@ files:
|
|
207
204
|
- lib/automan/ec2/errors.rb
|
208
205
|
- lib/automan/ec2/image.rb
|
209
206
|
- lib/automan/ec2/instance.rb
|
210
|
-
- lib/automan/elasticache/router.rb
|
211
207
|
- lib/automan/mixins/aws_caller.rb
|
212
208
|
- lib/automan/mixins/utils.rb
|
213
209
|
- lib/automan/rds/errors.rb
|
@@ -232,17 +228,9 @@ files:
|
|
232
228
|
- spec/cloudformation/uploader_spec.rb
|
233
229
|
- spec/ec2/image_spec.rb
|
234
230
|
- spec/ec2/instance_spec.rb
|
235
|
-
- spec/elasticache/router_spec.rb
|
236
231
|
- spec/mixins/aws_caller_spec.rb
|
237
232
|
- spec/mixins/utils_spec.rb
|
238
233
|
- spec/rds/snapshot_spec.rb
|
239
|
-
- templates/stacker/.env.example
|
240
|
-
- templates/stacker/.gitignore
|
241
|
-
- templates/stacker/.ruby-gemset.tt
|
242
|
-
- templates/stacker/.ruby-version
|
243
|
-
- templates/stacker/Gemfile
|
244
|
-
- templates/stacker/bin/%app_name%.tt
|
245
|
-
- templates/stacker/bin/launch_%app_name%.sh.tt
|
246
234
|
homepage: ''
|
247
235
|
licenses: []
|
248
236
|
metadata: {}
|
@@ -262,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
250
|
version: '0'
|
263
251
|
requirements: []
|
264
252
|
rubyforge_project:
|
265
|
-
rubygems_version: 2.
|
253
|
+
rubygems_version: 2.4.8
|
266
254
|
signing_key:
|
267
255
|
specification_version: 4
|
268
256
|
summary: Automates common AWS ops
|
@@ -283,7 +271,6 @@ test_files:
|
|
283
271
|
- spec/cloudformation/uploader_spec.rb
|
284
272
|
- spec/ec2/image_spec.rb
|
285
273
|
- spec/ec2/instance_spec.rb
|
286
|
-
- spec/elasticache/router_spec.rb
|
287
274
|
- spec/mixins/aws_caller_spec.rb
|
288
275
|
- spec/mixins/utils_spec.rb
|
289
276
|
- spec/rds/snapshot_spec.rb
|
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
automan
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.1.2
|
data/.travis.yml
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'automan'
|
2
|
-
|
3
|
-
module Automan::ElastiCache
|
4
|
-
class Router < Automan::Base
|
5
|
-
|
6
|
-
add_option :environment,
|
7
|
-
:hosted_zone_name,
|
8
|
-
:redis_host
|
9
|
-
|
10
|
-
def node_name_from_elasticache_environment(env)
|
11
|
-
|
12
|
-
opts = {
|
13
|
-
cache_cluster_id: "redis-#{env}",
|
14
|
-
show_cache_node_info: true
|
15
|
-
}
|
16
|
-
|
17
|
-
response = ec.client.describe_cache_clusters opts
|
18
|
-
|
19
|
-
unless response.successful?
|
20
|
-
raise RequestFailedError, "describe_cache_clusters failed: #{response.error}"
|
21
|
-
end
|
22
|
-
|
23
|
-
cluster=response.data[:cache_clusters]
|
24
|
-
if cluster.empty?
|
25
|
-
return nil
|
26
|
-
end
|
27
|
-
|
28
|
-
nodes=Hash[*cluster][:cache_nodes]
|
29
|
-
if nodes.empty?
|
30
|
-
return nil
|
31
|
-
end
|
32
|
-
|
33
|
-
endpoint=Hash[*nodes][:endpoint]
|
34
|
-
if endpoint.empty?
|
35
|
-
return nil
|
36
|
-
end
|
37
|
-
|
38
|
-
logger.info "found redis endpoint at #{endpoint[:address]}"
|
39
|
-
endpoint[:address]
|
40
|
-
end
|
41
|
-
|
42
|
-
# be sure alias_name ends in period
|
43
|
-
def update_dns_alias(zone_name, redis_cname, primary_endpoint)
|
44
|
-
zone = r53.hosted_zones.select {|z| z.name == zone_name}.first
|
45
|
-
rrset = zone.rrsets[redis_cname + '.', 'CNAME']
|
46
|
-
|
47
|
-
if rrset.exists?
|
48
|
-
logger.info "removing old record at #{redis_cname}"
|
49
|
-
rrset.delete
|
50
|
-
end
|
51
|
-
|
52
|
-
logger.info "creating record #{redis_cname} -> #{primary_endpoint}"
|
53
|
-
zone.rrsets.create(
|
54
|
-
redis_cname + '.',
|
55
|
-
'CNAME',
|
56
|
-
:ttl => 300,
|
57
|
-
:resource_records => [{:value => primary_endpoint}]
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def run
|
62
|
-
log_options
|
63
|
-
|
64
|
-
logger.info "getting redis primary node name..."
|
65
|
-
primary_endpoint = node_name_from_elasticache_environment environment
|
66
|
-
|
67
|
-
if primary_endpoint.nil?
|
68
|
-
false
|
69
|
-
else
|
70
|
-
update_dns_alias(
|
71
|
-
hosted_zone_name,
|
72
|
-
redis_host,
|
73
|
-
primary_endpoint
|
74
|
-
)
|
75
|
-
true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'automan'
|
2
|
-
|
3
|
-
describe Automan::ElastiCache::Router do
|
4
|
-
it { is_expected.to respond_to :run }
|
5
|
-
it { is_expected.to respond_to :environment }
|
6
|
-
it { is_expected.to respond_to :hosted_zone_name }
|
7
|
-
it { is_expected.to respond_to :redis_host }
|
8
|
-
|
9
|
-
describe '#run' do
|
10
|
-
subject() do
|
11
|
-
AWS.stub!
|
12
|
-
r = Automan::ElastiCache::Router.new
|
13
|
-
r.ec = AWS::ElastiCache::Client.new
|
14
|
-
r.environment = 'foo'
|
15
|
-
r.hosted_zone_name = 'foo.com'
|
16
|
-
r.redis_host = 'redis.foo.com'
|
17
|
-
r.logger = Logger.new('/dev/null')
|
18
|
-
r
|
19
|
-
end
|
20
|
-
|
21
|
-
it "raises error if it never finds a name" do
|
22
|
-
allow(subject).to receive(:node_name_from_elasticache_environment).and_return(nil)
|
23
|
-
expect {
|
24
|
-
subject.run
|
25
|
-
}.not_to raise_error
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# example .env file
|
3
|
-
# cp .env.example .env
|
4
|
-
#
|
5
|
-
# Set environment variables for all template parameters here.
|
6
|
-
# This .env file is in gitignore to help keep application
|
7
|
-
# secrets from leaking out into source code control.
|
8
|
-
#
|
9
|
-
export VPC_ID=vpc-foo
|
10
|
-
export SUBNET_ID=subnet-foo
|
11
|
-
export REMOTE_ACCESS_SG=sg-foo
|
12
|
-
export KEYPAIR_NAME=fookey
|
13
|
-
export INSTANCE_TYPE=m3.medium
|
14
|
-
export IMAGE_ID=ami-foo
|