health_inspector 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +6 -0
- data/health_inspector.gemspec +2 -0
- data/lib/health_inspector/checklists/base.rb +40 -4
- data/lib/health_inspector/checklists/cookbooks.rb +1 -1
- data/lib/health_inspector/checklists/data_bag_items.rb +3 -2
- data/lib/health_inspector/checklists/environments.rb +2 -2
- data/lib/health_inspector/checklists/roles.rb +2 -1
- data/lib/health_inspector/version.rb +1 -1
- metadata +20 -9
data/HISTORY.md
CHANGED
data/health_inspector.gemspec
CHANGED
@@ -69,7 +69,7 @@ module HealthInspector
|
|
69
69
|
if original[key].kind_of?(Hash) && other[key].kind_of?(Hash)
|
70
70
|
memo[key] = diff(original[key], other[key])
|
71
71
|
else
|
72
|
-
memo[key] =
|
72
|
+
memo[key] = {"server" => original[key],"local" => other[key]}
|
73
73
|
end
|
74
74
|
end
|
75
75
|
memo
|
@@ -97,10 +97,42 @@ module HealthInspector
|
|
97
97
|
puts color('bright fail', "- #{subject}")
|
98
98
|
|
99
99
|
failures.each do |message|
|
100
|
-
|
100
|
+
if message.kind_of? Hash
|
101
|
+
puts color('bright yellow'," has the following values mismatched on the server and repo\n")
|
102
|
+
print_failures_from_hash(message)
|
103
|
+
else
|
104
|
+
puts color('bright yellow', " #{message}")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def print_failures_from_hash(message, depth=2)
|
110
|
+
message.keys.each do |key|
|
111
|
+
print_key(key,depth)
|
112
|
+
|
113
|
+
if message[key].include? "server"
|
114
|
+
print_value_diff(message[key],depth)
|
115
|
+
message[key].delete_if { |k,v| k == "server" || "local" }
|
116
|
+
print_failures_from_hash(message[key], depth + 1) unless message[key].empty?
|
117
|
+
else
|
118
|
+
print_failures_from_hash(message[key], depth + 1)
|
119
|
+
end
|
101
120
|
end
|
102
121
|
end
|
103
122
|
|
123
|
+
def print_key(key, depth)
|
124
|
+
puts indent( color('bright yellow',"#{key} : "), depth )
|
125
|
+
end
|
126
|
+
|
127
|
+
def print_value_diff(value, depth)
|
128
|
+
print indent( color('bright fail',"server value = "), depth + 1 )
|
129
|
+
print value["server"]
|
130
|
+
print "\n"
|
131
|
+
print indent( color('bright fail',"local value = "), depth + 1 )
|
132
|
+
print value["local"]
|
133
|
+
print "\n\n"
|
134
|
+
end
|
135
|
+
|
104
136
|
def load_ruby_or_json_from_local(chef_class, folder, name)
|
105
137
|
path_template = "#{@context.repo_path}/#{folder}/#{name}.%s"
|
106
138
|
ruby_pathname = Pathname.new(path_template % "rb")
|
@@ -111,9 +143,9 @@ module HealthInspector
|
|
111
143
|
instance = chef_class.new
|
112
144
|
instance.from_file(ruby_pathname.to_s)
|
113
145
|
elsif json_pathname.exist?
|
114
|
-
instance = chef_class.json_create(
|
146
|
+
instance = chef_class.json_create( Yajl::Parser.parse( json_pathname.read ) )
|
115
147
|
elsif js_pathname.exist?
|
116
|
-
instance = chef_class.json_create(
|
148
|
+
instance = chef_class.json_create( Yajl::Parser.parse( js_pathname.read ) )
|
117
149
|
end
|
118
150
|
|
119
151
|
instance ? instance.to_hash : nil
|
@@ -121,6 +153,10 @@ module HealthInspector
|
|
121
153
|
nil
|
122
154
|
end
|
123
155
|
|
156
|
+
def indent(string, depth)
|
157
|
+
string.prepend(' ' * 2 * depth)
|
158
|
+
end
|
159
|
+
|
124
160
|
end
|
125
161
|
end
|
126
162
|
end
|
@@ -62,7 +62,7 @@ module HealthInspector
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def cookbooks_on_server
|
65
|
-
|
65
|
+
Yajl::Parser.parse( @context.knife_command("cookbook list -Fj") ).inject({}) do |hsh, c|
|
66
66
|
name, version = c.split
|
67
67
|
hsh[name] = version
|
68
68
|
hsh
|
@@ -15,7 +15,8 @@ module HealthInspector
|
|
15
15
|
|
16
16
|
add_check "items are the same" do
|
17
17
|
if item.server && item.local
|
18
|
-
|
18
|
+
item_diff = diff(item.server, item.local)
|
19
|
+
failure item_diff unless item_diff.empty?
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -61,7 +62,7 @@ module HealthInspector
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def load_item_from_local(name)
|
64
|
-
|
65
|
+
Yajl::Parser.parse( File.read("#{@context.repo_path}/data_bags/#{name}.json") )
|
65
66
|
rescue IOError, Errno::ENOENT
|
66
67
|
nil
|
67
68
|
end
|
@@ -15,8 +15,8 @@ module HealthInspector
|
|
15
15
|
|
16
16
|
add_check "items are the same" do
|
17
17
|
if item.server && item.local
|
18
|
-
|
19
|
-
failure
|
18
|
+
item_diff = diff(item.server, item.local)
|
19
|
+
failure item_diff unless item_diff.empty?
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -17,7 +17,8 @@ module HealthInspector
|
|
17
17
|
|
18
18
|
add_check "items are the same" do
|
19
19
|
if item.server && item.local
|
20
|
-
|
20
|
+
item_diff = diff(item.server, item.local)
|
21
|
+
failure item_diff unless item_diff.empty?
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: health_inspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70104583098760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70104583098760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70104583097840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70104583097840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: thor
|
38
|
-
requirement: &
|
38
|
+
requirement: &70104583097300 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70104583097300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: chef
|
49
|
-
requirement: &
|
49
|
+
requirement: &70104583096760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,18 @@ dependencies:
|
|
54
54
|
version: '10.14'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70104583096760
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yajl-ruby
|
60
|
+
requirement: &70104583096340 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70104583096340
|
58
69
|
description: A tool to inspect your chef repo as is compares to what is on your chef
|
59
70
|
server
|
60
71
|
email:
|