automan 2.1.3 → 2.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ff89fd6445234583d2dde7e5fa84d345cfdc736
4
- data.tar.gz: bf206d9978acd7cb472388df2bc8073b23af6443
3
+ metadata.gz: cc78fb2a5418be62e64d661b9c1f65704b069277
4
+ data.tar.gz: 5e13ddb9c298a1968b9398199e35a2ff4190800c
5
5
  SHA512:
6
- metadata.gz: ce434b18f4b4dd0a597a075719088fa4258bd2196baeca16668e3218099c5b232397f22a136001d0514e41dcf19b0a6e7e0e538c373e463d744d3aaa4c35af46
7
- data.tar.gz: 85a6e482d61a528271e3736b9c425b5976174986410992532a84b34e602d0690c393216dadf6b91f12e3e448bdaab7c48147b6f67bad3431206f1e72863ff96b
6
+ metadata.gz: 87496bd4374b42164b02c3da1d2fb2dde94ec72af45c7d4b705cb3cf51f31f65aa7272b2228c29288947ff7e3b33085d5c5215ed74bf200b2f436752140d9bfb
7
+ data.tar.gz: 14cdfb13a45f54d5de9f43278e140faaf60e11716fd8d839b6c2328839666d1c852e2a94756f76c4986abe81abacff4e70e164b02aa481d668283e3b6d0a95e4
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-2.1.2@automan
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.1.2"
4
+ # uncomment this line if your project needs to run something other than `rake`:
5
+ # script: bundle exec rspec spec
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -12,11 +12,9 @@ module Automan
12
12
 
13
13
  include Automan::Mixins::AwsCaller
14
14
 
15
- def initialize(options=nil)
15
+ def initialize(options={})
16
16
  $stdout.sync = true
17
17
  @logger = Logger.new(STDOUT)
18
- @log_aws_calls = false
19
- #@wait = Wait.new(rescuer: WaitRescuer.new, logger: @logger)
20
18
 
21
19
  if !options.nil?
22
20
  options.each_pair do |k,v|
@@ -24,6 +22,12 @@ module Automan
24
22
  send(accessor, v) if respond_to? accessor
25
23
  end
26
24
  end
25
+
26
+ aws_options = {}
27
+ if options[:log_aws]
28
+ aws_options[:logger] = @logger
29
+ end
30
+ configure_aws(aws_options)
27
31
  end
28
32
 
29
33
  def self.add_option(*args)
@@ -18,7 +18,7 @@ module Automan::Beanstalk
18
18
 
19
19
  include Automan::Mixins::Utils
20
20
 
21
- def initialize(options=nil)
21
+ def initialize(options={})
22
22
  @number_to_keep = 0
23
23
  super
24
24
  end
@@ -10,7 +10,7 @@ module Automan::Beanstalk
10
10
 
11
11
  attr_accessor :attempts_made
12
12
 
13
- def initialize(options=nil)
13
+ def initialize(options={})
14
14
  super
15
15
  @wait = Wait.new({
16
16
  attempts: 10,
@@ -37,8 +37,8 @@ module Automan::Cli
37
37
  exit 1
38
38
  end
39
39
 
40
+ options[:log_aws] = true
40
41
  s = Automan::RDS::Snapshot.new(options)
41
- s.log_aws_calls = true
42
42
  s.prune_snapshots if options[:prune]
43
43
  s.create
44
44
  end
@@ -74,26 +74,5 @@ module Automan::Cli
74
74
  Automan::RDS::Snapshot.new(options).latest
75
75
  end
76
76
 
77
- desc "count", "return the number of snapshots"
78
-
79
- option :environment,
80
- aliases: "-e",
81
- desc: "environment of database to snapshot"
82
-
83
- option :database,
84
- aliases: "-d",
85
- desc: "name of the database to snapshot"
86
-
87
- def count
88
-
89
- if options[:database].nil? && options[:environment].nil?
90
- puts "Must specify either database or environment"
91
- help "count"
92
- exit 1
93
- end
94
-
95
- Automan::RDS::Snapshot.new(options).count_snapshots
96
- end
97
-
98
77
  end
99
78
  end
@@ -16,7 +16,7 @@ module Automan::Cloudformation
16
16
 
17
17
  include Automan::Mixins::Utils
18
18
 
19
- def initialize(options=nil)
19
+ def initialize(options={})
20
20
  @wait_for_completion = false
21
21
  super
22
22
  @wait = Wait.new({
@@ -5,7 +5,7 @@ module Automan::Cloudformation
5
5
  class Replacer < Automan::Base
6
6
  add_option :name
7
7
 
8
- def initialize(options=nil)
8
+ def initialize(options={})
9
9
  super
10
10
  @wait = Wait.new({
11
11
  delay: 60,
@@ -4,7 +4,7 @@ module Automan::Cloudformation
4
4
  class Terminator < Automan::Base
5
5
  add_option :name, :wait_for_completion
6
6
 
7
- def initialize(options=nil)
7
+ def initialize(options={})
8
8
  @wait_for_completion = false
9
9
  super
10
10
  @wait = Wait.new({
@@ -7,7 +7,7 @@ module Automan::Ec2
7
7
 
8
8
  include Automan::Mixins::Utils
9
9
 
10
- def initialize(options=nil)
10
+ def initialize(options={})
11
11
  super
12
12
  @wait = Wait.new({
13
13
  delay: 5,
@@ -8,14 +8,20 @@ module Automan
8
8
  ENV['AWS_ACCOUNT_ID']
9
9
  end
10
10
 
11
- attr_reader :log_aws_calls
12
- def log_aws_calls=(value)
13
- if value == true
14
- AWS.config(logger: @logger)
15
- else
16
- AWS.config(logger: nil)
11
+ def configure_aws(options={})
12
+ if ENV['AWS_ROLE']
13
+ sts = AWS::STS.new
14
+
15
+ @logger.info "Assuming role #{ENV['AWS_ROLE']}"
16
+ provider = AWS::Core::CredentialProviders::AssumeRoleProvider.new(
17
+ sts: sts,
18
+ role_arn: ENV['AWS_ROLE'],
19
+ role_session_name: "automan-aws-sdk"
20
+ )
21
+ options[:credential_provider] = provider
17
22
  end
18
- @log_aws_calls = value
23
+
24
+ AWS.config(options)
19
25
  end
20
26
 
21
27
  attr_writer :eb
@@ -12,7 +12,7 @@ module Automan::RDS
12
12
 
13
13
  attr_accessor :max_snapshots
14
14
 
15
- def initialize(options=nil)
15
+ def initialize(options={})
16
16
  @prune = true
17
17
  @wait_for_completion = false
18
18
  super
@@ -63,7 +63,7 @@ module Automan::RDS
63
63
  end
64
64
 
65
65
  def snapshot_count
66
- rds.db_instances[find_db.id].snapshots.count
66
+ rds.db_instances[database].snapshots.count
67
67
  end
68
68
 
69
69
  def create
@@ -204,14 +204,12 @@ module Automan::RDS
204
204
  end
205
205
 
206
206
  def get_all_snapshots
207
- rds.db_instances[find_db.id].snapshots
207
+ rds.db_snapshots
208
208
  end
209
209
 
210
210
  def prunable_snapshots
211
- AWS.memoize do
212
- snapshots = get_all_snapshots
213
- snapshots.select { |s| can_prune?(s) }
214
- end
211
+ snapshots = get_all_snapshots
212
+ snapshots.select { |s| can_prune?(s) }
215
213
  end
216
214
 
217
215
  def oldest_prunable_snapshot
@@ -235,17 +233,6 @@ module Automan::RDS
235
233
  end
236
234
  end
237
235
 
238
- def count_snapshots
239
- log_options
240
- db = find_db
241
- if db.nil?
242
- logger.info "Database not found"
243
- else
244
- logger.info "Number of snapshots for database #{db.id} is #{snapshot_count}"
245
- logger.info "Number of prunable snapshots for database #{db.id} is #{prunable_snapshots.count}"
246
- end
247
- end
248
-
249
236
  def latest
250
237
  log_options
251
238
  db = find_db
@@ -254,4 +241,4 @@ module Automan::RDS
254
241
  logger.info "Most recent snapshot is #{s.id}"
255
242
  end
256
243
  end
257
- end
244
+ end
@@ -1,3 +1,3 @@
1
1
  module Automan
2
- VERSION = "2.1.3"
2
+ VERSION = "2.2.2"
3
3
  end
@@ -17,7 +17,6 @@ describe Automan::Beanstalk::Router do
17
17
  r.environment_name = 'foo'
18
18
  r.hosted_zone_name = 'foo.com'
19
19
  r.hostname = 'www.foo.com'
20
- r.log_aws_calls = false
21
20
  r.logger = Logger.new('/dev/null')
22
21
  r.wait = Wait.new(delay: 0.01, rescuer: WaitRescuer.new(AWS::Route53::Errors::InvalidChangeBatch))
23
22
  r
@@ -16,7 +16,6 @@ describe Automan::Beanstalk::Version do
16
16
  v.eb = AWS::ElasticBeanstalk::Client.new
17
17
  v.application = 'foo'
18
18
  v.label = 'v4'
19
- v.log_aws_calls = false
20
19
  v.logger = Logger.new('/dev/null')
21
20
  v
22
21
  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.1.3
4
+ version: 2.2.2
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-10-16 00:00:00.000000000 Z
12
+ date: 2015-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -166,6 +166,8 @@ extensions: []
166
166
  extra_rdoc_files: []
167
167
  files:
168
168
  - ".gitignore"
169
+ - ".rvmrc"
170
+ - ".travis.yml"
169
171
  - Gemfile
170
172
  - LICENSE.txt
171
173
  - README.md
@@ -250,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
252
  version: '0'
251
253
  requirements: []
252
254
  rubyforge_project:
253
- rubygems_version: 2.4.8
255
+ rubygems_version: 2.2.2
254
256
  signing_key:
255
257
  specification_version: 4
256
258
  summary: Automates common AWS ops