Sha256: 0a0e696fa6a405b32bb3ab37d371ce0fba48546495c55df621b919642acee40e

Contents?: true

Size: 1.9 KB

Versions: 38

Compression:

Stored size: 1.9 KB

Contents

<%= render_file('common/header.html.erb', title: 'Nodes') %><%
service_tag_filter = ENV['SERVICES_TAG_FILTER'] || nil
# Services to hide
services_blacklist = (ENV['EXCLUDE_SERVICES'] || 'consul-agent-http,mesos-slave,mesos-agent-watcher,mesos-exporter-slave').split(',')

service_per_node = {}
services.each do |service_name, tags|
  if !services_blacklist.include? service_name
    service(service_name, tag: service_tag_filter).sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
      node_services = service_per_node[snode['Node']['Node']] || []
      node_services.push(snode)
      service_per_node[snode['Node']['Node']] = node_services
    end
  end
end %>

<h1 id="nodes">List all nodes for DC, sorted by name</h1>
<ul class="list-group">
<% nodes.sort {|a,b| a['Node'] <=> b['Node'] }.each do |snode|
%><li id="node_<%= snode['ID'] %>" class="list-group-item">
    <a href="ssh://<%= snode['Address']%>"><%= snode['Address'] %></a> <%= snode['Node'] %><%
  snode['Meta'].each do |k,v|
    if v && !v.empty?
%><span class="badge badge-pill badge-primary float-right"><%= k %>:&nbsp;<%= v%></span><%
    end
  end if snode['Meta']
  %><div><%
  if service_per_node.key?(snode['Node'])
    service_per_node[snode['Node']].each do |service|
      tags = service['Service']['Tags'].sort
      addr = service.service_address
      port_num = service['Service']['Port'].to_i
      port = port_num && port_num > 0 ? ":#{port_num}" : ''
      url = if tags.include? 'https'
              "https://#{addr}#{port}"
            elsif tags.include? 'http'
              "http://#{addr}#{port}"
            elsif tags.include? 'ftp'
              "ftp://#{addr}#{port}"
            else
              nil
            end
    %> <a class="badge badge-secondary" href='<%= url %>'>
    <%= service['Service']['Service'] %>: <%= port_num %>
    </a>
  <% end
  end
%></div></li>
<% end %>
</ul>
<%= render_file 'common/footer.html.erb' %>

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
consul-templaterb-1.9.8 samples/nodes.html.erb
consul-templaterb-1.9.7 samples/nodes.html.erb
consul-templaterb-1.9.6 samples/nodes.html.erb
consul-templaterb-1.9.5 samples/nodes.html.erb
consul-templaterb-1.9.4 samples/nodes.html.erb
consul-templaterb-1.9.3 samples/nodes.html.erb
consul-templaterb-1.9.2 samples/nodes.html.erb
consul-templaterb-1.9.1 samples/nodes.html.erb
consul-templaterb-1.9.0 samples/nodes.html.erb
consul-templaterb-1.8.8 samples/nodes.html.erb
consul-templaterb-1.8.7 samples/nodes.html.erb
consul-templaterb-1.8.6 samples/nodes.html.erb
consul-templaterb-1.8.5 samples/nodes.html.erb
consul-templaterb-1.8.4 samples/nodes.html.erb
consul-templaterb-1.8.3 samples/nodes.html.erb
consul-templaterb-1.8.2 samples/nodes.html.erb
consul-templaterb-1.8.1 samples/nodes.html.erb
consul-templaterb-1.8.0 samples/nodes.html.erb
consul-templaterb-1.7.0 samples/nodes.html.erb
consul-templaterb-1.6.3 samples/nodes.html.erb