Module: Hieracles::Registry

Extended by:
Registry
Included in:
Registry
Defined in:
lib/hieracles/registry.rb

Instance Method Summary collapse

Instance Method Details

#farms(config) ⇒ Object



6
7
8
9
10
11
# File 'lib/hieracles/registry.rb', line 6

def farms(config)
	Dir.glob(format(config.classpath, '*')).sort.map do |f|
     sub = Regexp.new(".*#{config.classpath.sub(/%s/,'([^/]*)')}")
     f.sub(sub, "\\1")
   end
end

#modules(config) ⇒ Object



19
20
21
22
23
# File 'lib/hieracles/registry.rb', line 19

def modules(config)
	Dir.glob(File.join(config.modulepath, '*')).sort.map do |f|
		File.basename(f)
	end
end

#nodes(config) ⇒ Object



13
14
15
16
17
# File 'lib/hieracles/registry.rb', line 13

def nodes(config)
	Dir.glob(File.join(config.encpath, '*.yaml')).sort.map do |f|
		File.basename(f, '.yaml')
	end
end

#nodes_data(config, env = 'production', reload = false) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/hieracles/registry.rb', line 25

def nodes_data(config, env = 'production', reload = false)
  @_nodes_data = {} if reload || !@_nodes_data
  @_nodes_data[env] ||= Dir.glob(File.join(config.encpath, '*.yaml')).sort.reduce({}) do |a, f|
    fqdn = File.basename(f, '.yaml')
    a[fqdn] = YAML.load_file(f)['parameters']
    a
  end
end