reyes 0.0.5 → 0.0.6

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmI5ZGU3MDc0MDc1NWQ0ODUzYjNmZjc3MWI2Y2ZlZjdmZjE4YjY5Ng==
4
+ YjM4MDllMmJmMGJiZjZjZGZiMDIwYTAzMDc4YjViYzJmODA2YWVmZQ==
5
5
  data.tar.gz: !binary |-
6
- NzUxNTdlN2MwNTlmYWE4MGI5M2I1YjcyMzQxOWY1ZjhjYjY2ZTNiMg==
6
+ MDZjZTU2MjIxZTZhY2FmMTc1ODU4YjkyNzEyYWNmOTIwYzU5Yjk0NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2ViZDI2MjA0YjhjNWNiOWFkNGQzNmQwYzE2ZDQxYWUxNzI4NTI5NTUyNTQ2
10
- MTQxYjBkZTk5NWJiOTQ2MjZmZGEzODViODk0N2UwZGY2YmZmZmE1NzdhMGVm
11
- Njg0MTg4MmE2MjBhMWJhZTcwYTcwNzhiYjNlNTQ1ZGM0MTQwM2Y=
9
+ NTNlNDgyMjg3Mzg0NzdiYjRmY2QxYTRlNGZkMDhmNzA3NDQyZTg2MWMzN2Ez
10
+ YmJkNmQ4NmZlNGY5NWJjOGQ5MjYxNzkzMGJhZTk1MjQzOTUzYjQyN2YwYjM2
11
+ ZWVkMmRlNmY0MWY3NTc4OWRjZjBiNzI0NTQ1OGJiY2RjNDdmMWY=
12
12
  data.tar.gz: !binary |-
13
- YmJjYzVkNDEwOGJiYThhNTg3N2VhMmUzNTdlZDBjY2U1ZjRiZjNhMTA2ZWVi
14
- YzkyY2Y1ZjgyYzM4NDYyOGYwZjUwMjAwOWEwNzIxYWJmNTg3NDI0ZWUxMzli
15
- ZjRmODI5NGYwZjcxMWE5NjgzM2ZjYmQ0N2Y0NjRmNGE3MzYyZTU=
13
+ NTZlNTU4MGRmZDExNWUwNWEwZDQ2NmE3MDNjMWJjOGU2N2U5MzdkZDhiNjBj
14
+ YjBlNzlhNDJiZjUzMDAwZWJiNzIxMmY2NjFjZTkxYjcyNWQ3NmYxNjE5MjQ4
15
+ YTMwODEyMjY5YjYyMWRiMmE2NTk3MWZjMGY2Y2E4N2RmYjljMGE=
data/bin/reyes CHANGED
@@ -64,6 +64,11 @@ Options:
64
64
  options[:instance_id] = id
65
65
  end
66
66
 
67
+ # TODO: known bug: --dry-run does not prevent run generation increment
68
+ opts.on('-n', '--dry-run', 'Print diff without making changes') do
69
+ options[:run_options][:dry_run] = true
70
+ end
71
+
67
72
  opts.on('-i', '--interactive', 'Interactively confirm changes') do
68
73
  options[:run_options][:interactive] = true
69
74
  end
@@ -93,11 +93,15 @@ module Reyes
93
93
  sg.vpc.instances.find_all {|i| i.security_groups.include?(sg)}
94
94
  end
95
95
 
96
- # TODO: remove (probably not needed)
97
96
  def warm_sg_cache
98
- connections.fetch(:ec2).each_pair do |region, ec2|
99
- log.debug("Warming security group cache for #{region}")
100
- ec2.security_groups.to_a
97
+ unless AWS.memoizing?
98
+ log.warn("Calling warm_sg_cache doesn't make sense unless memoizing")
99
+ end
100
+ log.info("Warming security group caches")
101
+ vpcs.each do |vpc|
102
+ log.debug("Warming security group cache for #{vpc.id}")
103
+ sg = vpc.security_groups.to_a.first
104
+ instances_in_security_group(sg)
101
105
  end
102
106
  end
103
107
 
@@ -25,6 +25,7 @@ module Reyes
25
25
 
26
26
  def initialize(aws, region, instance_id, config_file=nil, generation=nil)
27
27
  log.info("Initializing #{self.class.name} for #{region} #{instance_id}")
28
+ log.info("This is reyes #{Reyes::VERSION}")
28
29
 
29
30
  @aws = aws
30
31
  @generation = generation || RunGeneration.new
@@ -59,6 +60,8 @@ module Reyes
59
60
  run_generation_increment!
60
61
  log.info("Generating rules for generation #{run_generation}")
61
62
 
63
+ @aws.warm_sg_cache
64
+
62
65
  data = generate_rules_empty
63
66
 
64
67
  needed_groups = {}
@@ -8,6 +8,7 @@ module Reyes
8
8
 
9
9
  # @param [Hash] options
10
10
  #
11
+ # @option options :dry_run [Boolean] (false) Don't actually apply changes
11
12
  # @option options :empty [Boolean] (false) Generate an empty (default DROP)
12
13
  # rule sets without actually looking up security groups
13
14
  # @option options :interactive [Boolean] (false) Whether to prompt for
@@ -17,6 +18,7 @@ module Reyes
17
18
  #
18
19
  def run!(options={})
19
20
  options = {
21
+ dry_run: false,
20
22
  empty: false,
21
23
  interactive: false,
22
24
  log_accept: false,
@@ -39,6 +41,11 @@ module Reyes
39
41
  show_iptables_diff(new_rules)
40
42
  show_ipsets_diff(new_ipsets)
41
43
 
44
+ if options.fetch(:dry_run)
45
+ log.info('Dry run! Not applying changes')
46
+ return
47
+ end
48
+
42
49
  if options.fetch(:interactive)
43
50
  puts 'Press enter to continue...'
44
51
  STDIN.gets
data/lib/reyes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Reyes
2
- VERSION = '0.0.5' unless defined?(self::VERSION)
2
+ VERSION = '0.0.6' unless defined?(self::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reyes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Brody