outliers 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +43 -41
- data/lib/outliers/credentials.rb +0 -13
- data/lib/outliers/run.rb +8 -9
- data/lib/outliers/version.rb +1 -1
- data/spec/credentials_spec.rb +0 -21
- data/spec/run_spec.rb +23 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dcb9ddc49eb2c32e3716d6dd090fd7d1f98c3d9
|
4
|
+
data.tar.gz: 5516ddb04d0b89be33e4e6d8d7c013f512ed2d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea89d2a78e78dbbdb296e4666d4fb1bb1c75d442fe094856f9ea79202b4fe7c02cecb710235e3124b6cbfe46da9d86f1373004836cac231dd1917fc8a28ae501
|
7
|
+
data.tar.gz: 0e6532c2846d0bbda51586a874823102328ba051aa2e2db5dfc7617488d8f3d3c4d7cbadcabe7f74033e3faa8fa2334a593eb2245078d06a524ea544197b5ac8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/brettweavnet/outliers.png)](http://travis-ci.org/brettweavnet/outliers)
|
2
|
+
|
1
3
|
# Outliers
|
2
4
|
|
3
5
|
Outliers is a framework for verifying configuration of resources.
|
@@ -90,83 +92,83 @@ To process a directory:
|
|
90
92
|
|
91
93
|
To verify all instances are in a VPC, create the file **ec2.rb** and add the following block:
|
92
94
|
|
93
|
-
evaluate do
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
evaluate do
|
96
|
+
connect 'aws_prod', provider: 'aws_ec2'
|
97
|
+
resources 'instance'
|
98
|
+
verify 'vpc'
|
97
99
|
end
|
98
100
|
|
99
101
|
Files can have multiple evaluations, to add a validation that overrides the region:
|
100
102
|
|
101
|
-
evaluate do
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
evaluate do
|
104
|
+
connect 'aws_prod', provider: 'aws_ec2'
|
105
|
+
resources 'instance'
|
106
|
+
verify 'vpc'
|
105
107
|
end
|
106
108
|
|
107
|
-
evaluate do
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
evaluate do
|
110
|
+
connect 'aws_prod', provider: 'aws_ec2', region: 'us-west-1'
|
111
|
+
resources 'instance'
|
112
|
+
verify 'vpc'
|
111
113
|
end
|
112
114
|
|
113
115
|
The DSL supports any valid Ruby code. To iterate over multiple regions:
|
114
116
|
|
115
117
|
['us-west-1', 'us-west-2', 'us-east-1'].each do |region|
|
116
|
-
evaluate do
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
evaluate do
|
119
|
+
connect 'aws_prod', provider: 'aws_ec2', region: region
|
120
|
+
resources 'instance'
|
121
|
+
verify 'vpc'
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
125
|
Evaluations can be given names to help identify Outliers in results.
|
124
126
|
|
125
|
-
evaluate "validate_database_retention_period" do
|
126
|
-
|
127
|
-
|
128
|
-
|
127
|
+
evaluate "validate_database_retention_period" do
|
128
|
+
connect 'aws_prod', provider: 'aws_rds', region: 'us-west-1'
|
129
|
+
resources 'db_instance'
|
130
|
+
verify 'backup_retention_period', days: 2
|
129
131
|
end
|
130
132
|
|
131
133
|
To pass arguments to a verification:
|
132
134
|
|
133
|
-
evaluate do
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
evaluate do
|
136
|
+
connect 'aws_prod', provider: 'aws_rds', region: 'us-west-1'
|
137
|
+
resources 'db_instance'
|
138
|
+
verify 'backup_retention_period', days: 2
|
137
139
|
end
|
138
140
|
|
139
141
|
To pass multiple arguments, specify them as an array:
|
140
142
|
|
141
|
-
evaluate do
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
evaluate do
|
144
|
+
connect 'aws_prod', provider: 'aws_ec2', region: 'us-west-1'
|
145
|
+
resources 'instance'
|
146
|
+
verify 'valid_image_id', image_ids: ['ami-12345678','ami-87654321']
|
145
147
|
end
|
146
148
|
|
147
149
|
To only target a specific resource:
|
148
150
|
|
149
|
-
evaluate do
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
evaluate do
|
152
|
+
connect 'aws_prod', provider: 'aws_ec2', region: 'us-west-1'
|
153
|
+
resources 'instance', 'i-12345678'
|
154
|
+
verify 'valid_image_id', image_ids: ['ami-12345678','ami-87654321']
|
153
155
|
end
|
154
156
|
|
155
157
|
To target multiple resources, you can pass an array:
|
156
158
|
|
157
|
-
evaluate do
|
158
|
-
|
159
|
-
|
160
|
-
|
159
|
+
evaluate do
|
160
|
+
connect 'aws_prod', provider: 'aws_ec2', region: 'us-west-1'
|
161
|
+
resources 'instance', ['i-12345678', 'i-abcdef12']
|
162
|
+
verify 'valid_image_id', image_ids: ['ami-12345678','ami-87654321']
|
161
163
|
end
|
162
164
|
|
163
165
|
Sometimes you want to exclude resources that are known exceptions, to exclude an instance from the VPC validation:
|
164
166
|
|
165
|
-
evaluate do
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
evaluate do
|
168
|
+
connect 'aws_prod', provider: 'aws_ec2', region: 'us-west-1'
|
169
|
+
resources 'instance'
|
170
|
+
exclude 'i-12345678'
|
171
|
+
verify 'valid_image_id', image_ids: ['ami-12345678','ami-87654321']
|
170
172
|
end
|
171
173
|
|
172
174
|
### Help
|
data/lib/outliers/credentials.rb
CHANGED
@@ -2,19 +2,6 @@ module Outliers
|
|
2
2
|
module Credentials
|
3
3
|
module_function
|
4
4
|
|
5
|
-
# To Do - Remove me once validated not needed
|
6
|
-
def load_from_config_folder
|
7
|
-
credentials = {}
|
8
|
-
files = Dir.entries(File.join(Outliers.config_path, 'credentials')) - ['.', '..']
|
9
|
-
files.each do |file|
|
10
|
-
contents = File.read File.join(Outliers.config_path, 'credentials', file)
|
11
|
-
YAML.load(contents).each_pair do |k,v|
|
12
|
-
credentials[k] = v
|
13
|
-
end
|
14
|
-
end
|
15
|
-
credentials
|
16
|
-
end
|
17
|
-
|
18
5
|
def load_from_file(file)
|
19
6
|
credentials = {}
|
20
7
|
contents = File.read file
|
data/lib/outliers/run.rb
CHANGED
@@ -8,18 +8,17 @@ module Outliers
|
|
8
8
|
|
9
9
|
def process_evaluations_in_config_folder
|
10
10
|
evaluations_path = File.join Outliers.config_path
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
11
|
+
files = Dir.glob(File.join(evaluations_path, '**', '*'))
|
12
|
+
files.each do |file|
|
13
|
+
next if File.directory? file
|
14
|
+
next if File.extname(file) != '.rb'
|
15
|
+
logger.info "Processing '#{file}'."
|
16
|
+
self.instance_eval File.read(file)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
def evaluate(name='unspecified')
|
22
|
-
|
20
|
+
def evaluate(name='unspecified', &block)
|
21
|
+
Evaluation.new(:name => name, :run => self).instance_eval &block
|
23
22
|
end
|
24
23
|
|
25
24
|
def passed
|
data/lib/outliers/version.rb
CHANGED
data/spec/credentials_spec.rb
CHANGED
@@ -4,27 +4,6 @@ describe Outliers::Credentials do
|
|
4
4
|
subject { Outliers::Credentials }
|
5
5
|
let(:credentials1) { fixture_file 'credentials1.yml' }
|
6
6
|
let(:credentials2) { fixture_file 'credentials2.yml' }
|
7
|
-
context "#load_from_config_folder" do
|
8
|
-
before { Outliers.config_path '/test' }
|
9
|
-
it "should load the credentials from each file in the directory" do
|
10
|
-
Dir.should_receive(:entries).with('/test/credentials').
|
11
|
-
and_return ['.', '..', 'test1.yml', 'test2.yml']
|
12
|
-
File.should_receive(:read).with('/test/credentials/test1.yml').and_return credentials1
|
13
|
-
File.should_receive(:read).with('/test/credentials/test2.yml').and_return credentials2
|
14
|
-
results = { "test_credentials_1" =>
|
15
|
-
{ "region" => "us-west-1",
|
16
|
-
"provider" => "aws_ec2",
|
17
|
-
"access_key_id" => "01234567890123456789",
|
18
|
-
"secret_access_key" =>"0123456789012345678901234567890123456789" },
|
19
|
-
"test_credentials_2" =>
|
20
|
-
{ "region" => "us-west-1",
|
21
|
-
"provider" => "aws_ec2",
|
22
|
-
"access_key_id" => "01234567890123456789",
|
23
|
-
"secret_access_key" => "0123456789012345678901234567890123456789" }
|
24
|
-
}
|
25
|
-
expect(subject.load_from_config_folder).to eq(results)
|
26
|
-
end
|
27
|
-
end
|
28
7
|
|
29
8
|
context "#load_from_file" do
|
30
9
|
it "should load the credentials from the given yaml file" do
|
data/spec/run_spec.rb
CHANGED
@@ -6,28 +6,42 @@ describe Outliers::Run do
|
|
6
6
|
|
7
7
|
before do
|
8
8
|
stub_logger
|
9
|
+
Outliers.config_path '/test'
|
9
10
|
end
|
10
11
|
|
11
12
|
describe "#process_evaluations_in_config_folder" do
|
12
|
-
it "should process all
|
13
|
-
|
13
|
+
it "should process all .rb files in config folder and sub folders" do
|
14
|
+
files = ['/test/test1.rb', '/test/dir', '/test/dir/test2.rb', '/test/dir/test_other_file']
|
15
|
+
Dir.should_receive(:glob).with('/test/**/*').and_return files
|
16
|
+
|
17
|
+
['/test/test1.rb', '/test/dir/test2.rb', '/test/dir/test_other_file'].each do |f|
|
18
|
+
File.should_receive(:directory?).with(f).and_return false
|
19
|
+
end
|
20
|
+
File.should_receive(:directory?).with('/test/dir').and_return true
|
21
|
+
|
14
22
|
File.should_receive(:read).with('/test/test1.rb').and_return evaluation1
|
15
|
-
File.should_receive(:read).with('/test/test2.rb').and_return evaluation2
|
23
|
+
File.should_receive(:read).with('/test/dir/test2.rb').and_return evaluation2
|
16
24
|
|
17
25
|
subject.should_receive(:instance_eval).with(evaluation1)
|
18
26
|
subject.should_receive(:instance_eval).with(evaluation2)
|
19
27
|
subject.process_evaluations_in_config_folder
|
20
28
|
end
|
21
|
-
|
22
|
-
it "should skip directories"
|
23
|
-
it "should only evaluate .rb files"
|
24
29
|
end
|
25
30
|
|
26
31
|
describe "#evaluate" do
|
27
|
-
it "should kick off a new evaluation and
|
32
|
+
it "should kick off a new evaluation and pass the block for execuation" do
|
28
33
|
Outliers::Evaluation.should_receive(:new).with(:name => 'my evaluation', :run => subject).and_return evaluation1
|
29
|
-
|
30
|
-
|
34
|
+
evaluation1.should_receive(:connect).with('test')
|
35
|
+
subject.evaluate 'my evaluation' do
|
36
|
+
connect 'test'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should kick off a new evaluation with unspecified name" do
|
41
|
+
Outliers::Evaluation.should_receive(:new).with(:name => 'unspecified', :run => subject).and_return evaluation1
|
42
|
+
evaluation1.should_receive(:connect).with('test')
|
43
|
+
subject.evaluate do
|
44
|
+
connect 'test'
|
31
45
|
end
|
32
46
|
end
|
33
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outliers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|