Class: HealthInspector::Checklists::Roles
- Inherits:
-
Base
- Object
- Base
- HealthInspector::Checklists::Roles
show all
- Defined in:
- lib/health_inspector/checklists/roles.rb
Defined Under Namespace
Classes: Role
Instance Method Summary
collapse
Methods inherited from Base
add_check, #banner, #checks, #chef_rest, #indent, #initialize, #load_ruby_or_json_from_local, #print_failures, #print_failures_from_hash, #print_key, #print_success, #print_value_diff, #run, run, #run_check, #run_checks
#color
Instance Method Details
#each_item ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/health_inspector/checklists/roles.rb', line 27
def each_item
server_items = items_on_server
local_items = items_in_repo
all_item_names = ( server_items + local_items ).uniq.sort
all_item_names.each do |name|
item = Role.new.tap do |item|
item.name = name
item.server = load_item_from_server(name)
item.local = load_item_from_local(name)
end
yield item
end
end
|
#items_in_repo ⇒ Object
47
48
49
50
51
|
# File 'lib/health_inspector/checklists/roles.rb', line 47
def items_in_repo
Dir.chdir("#{@context.repo_path}/roles") do
Dir["*.{rb,json,js}"].map { |e| e.gsub(/\.(rb|json|js)/, '') }
end
end
|
#items_on_server ⇒ Object
43
44
45
|
# File 'lib/health_inspector/checklists/roles.rb', line 43
def items_on_server
@items_on_server ||= Chef::Role.list.keys
end
|
#load_item_from_local(name) ⇒ Object
60
61
62
|
# File 'lib/health_inspector/checklists/roles.rb', line 60
def load_item_from_local(name)
load_ruby_or_json_from_local(Chef::Role, "roles", name)
end
|
#load_item_from_server(name) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/health_inspector/checklists/roles.rb', line 53
def load_item_from_server(name)
role = Chef::Role.load(name)
role.to_hash
rescue
nil
end
|