24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'puppet/modules/wmflib/lib/puppet/parser/functions/get_clusters.rb', line 24
newfunction(:get_clusters, :type => :rvalue) do |args|
all = {}
cluster_config = call_function(:hiera, ['ganglia_clusters', {}])
selector ||= {}
selector = args[0] unless args.empty?
if selector.include? 'cluster'
clusters = selector['cluster']
else
clusters = cluster_config.keys
end
if selector.include? 'site'
sites = selector['site']
else
sites = false
end
function_query_resources([false, 'Class["Profile::Cumin::Target"]', false, 'certname asc']).each do |node|
cluster = node['parameters']['cluster']
site = node['parameters']['site']
fqdn = node['certname']
next unless clusters.include?cluster
next if sites && !sites.include?(site)
all[cluster] ||= {}
all[cluster][site] ||= []
all[cluster][site] << fqdn
end
all
end
|