-
Notifications
You must be signed in to change notification settings - Fork 29
/
consul_template.txt.erb
45 lines (37 loc) · 1.32 KB
/
consul_template.txt.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+ List of all datacenters
-------------------------
<% datacenters.each do |dc| %>
* <%= dc %> with <%= services(dc:dc).keys.count %> services, <%= nodes(dc:dc).count %> nodes
<% end %>
===========
+ List of all services in current DC
------------------------------------
<% services.each do |service_name, tags|
%> * <%= service_name %> [ <%= tags %> ]
<% end %>
===========
+ List all services instances with http tag on current DC, instances sorted by node name
----------------------------------------------------------------------------------------
<% services.each do |service_name, tags|
if tags.include? 'http'
%> ++ Service <%= service_name %>
<% service(service_name, tag:'http').sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
%> * <%= service_name %> -> <%=
snode['Node']['Node'] %>:<%= snode['Service']['Port'] %> <%=
snode['Service']['Tags'] %> status: <%
snode['Checks'].each do |c| %> <%= c['Status']
%><% end if snode['Checks'] %>
<% end
end
end %>
===========
+ List all nodes for DC, sorted by name
---------------------------------------
<% nodes.sort {|a,b| a['Node'] <=> b['Node'] }.each do |snode|
%> * <%= snode['Address'].ljust(16) %> <%= snode['Node'] %>
<% end %>
+ KV of Current DC
------------------
<% kv(keys:true).each do |key|
%> * <%= key %>
<% end %>