Guest User

Untitled

a guest
Apr 5th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.63 KB | None | 0 0
  1. # Host definitions
  2. #
  3. # Autogenerated by Chef.
  4.  
  5. define host {
  6.   use server
  7.   address <%= node['ipaddress'] %>
  8.   host_name <%= node[node['nagios']['host_name_attribute']] %>
  9.   hostgroups <%= node['nagios']['server_role'] %>,<%= node['os'] %>
  10. }
  11.  
  12. <% @nodes.each do |n| -%>
  13. <% unless n.name == node.name -%>
  14. define host {
  15.   use server
  16.   <%
  17.   if node['cloud'].nil? && !n['cloud'].nil?
  18.     ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
  19.   elsif !node['cloud'].nil? && n['cloud']['provider'] != node['cloud']['provider']
  20.     ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
  21.   else
  22.     ip = n['ipaddress']
  23.   end %>
  24.   address <%= ip %>
  25.   host_name <%= n[node['nagios']['host_name_attribute']] %>
  26.   <% if node['nagios']['multi_environment_monitoring'] -%>
  27.   <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  28.   hostgroups all,<%= n.os %>, <%= n.chef_environment %>
  29.   <% else -%>
  30.   hostgroups <%= (n.run_list.roles.to_a & @hostgroups).join(",") %>,<%= n.os %>, <%= n.chef_environment %>
  31.   <% end -%>
  32.   <% elsif -%>
  33.   <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  34.   hostgroups all,<%= n.os %>
  35.   <% else -%>
  36.   hostgroups <%= (n.run_list.roles.to_a & @hostgroups).join(",") %>,<%= n['os'] %>
  37.   <% end -%>
  38.   <% end -%>
  39. }
  40. <% end -%>
  41. <% end -%>
  42.  
  43. <% unless @unmanaged_hosts.nil? -%>
  44. <% @unmanaged_hosts.each do |n| -%>
  45. define host {
  46.   use server
  47.   address <%= n['address'] %>
  48.   host_name <%= n['id'] %>
  49.   hostgroups <%= n['hostgroups'].join(",") %>
  50.   notifications_enabled <%= n['notifications'] %>
  51. }
  52. <% end -%>
  53. <% end -%>
Advertisement
Add Comment
Please, Sign In to add comment