Skip to content

Instantly share code, notes, and snippets.

@macros
Created February 27, 2009 02:11
Show Gist options
  • Save macros/71238 to your computer and use it in GitHub Desktop.
Save macros/71238 to your computer and use it in GitHub Desktop.
hosts = Hash.new
search(:node, "*") do |server|
hosts[server[:ipaddress]] << server[:hostname]
end
template "/tmp/hosts" do
source "hosts.erb"
mode 0644
owner "root"
group "root"
variables(
:hostname => node[:hostname],
:ipaddress => node[:ipaddress],
:hosts => hosts
)
end
127.0.0.1 localhost
<%= @ipaddress %> <%= "#{@hostname}.local #{@hostname}" %>
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
<% @hosts.each do |ip,host| %>
<%= "#{ip} #{host}" %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment