cookbooks/mu-tools/templates/default/etc_hosts.erb
::1 localhost6.localdomain6 localhost6
<%= @ipaddress %> <%= @hostname %>
127.0.0.1 localhost
<% if !@nodes.nil? and !@nodes.empty?
@nodes.each{ |n|
# doing only private IPs although that can be problematic
# if the same deploy has cross VPC or cross region resources
if n.name != @hostname %>
<%= n['ipaddress'] %> <%= n.name %>
<%
end
}
else
if !node['deployment'].nil? and !node['deployment']['servers'].nil?
node['deployment']['servers'].each_pair { |nodetype, sibling_struct|
next if !sibling_struct.is_a?(Hash)
sibling = sibling_struct.values.each { |sibling|
next if !sibling.is_a?(Hash)
next if sibling['nodename'] == @hostname
if !sibling['public_ip_address'].nil? %>
<%= sibling['public_ip_address'] %> <%= sibling['nodename'] %>
<% else %>
<%= sibling['private_ip_address'] %> <%= sibling['nodename'] %>
<%
end
}
}
end
end
%>