# Host definitions
#
# Autogenerated by Chef.

<% @nodes.each do |n| -%>
define host {
  use server
  address <%= (!n['cloud'].nil? && n['cloud'] != node['cloud']) ? n['cloud']['public_ipv4'] : n['ipaddress'] %>
  host_name <%= n['hostname'] %>
  <% if node['nagios']['multi_environment_monitoring'] -%>
  <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  hostgroups all,<%= n.os %>,<%= n.chef_environment %>
  <% else -%>
  hostgroups <%= (n.run_list.roles.to_a & @hostgroups).join(",") %>,<%= n.os %>,<%= n.chef_environment %>
  <% end -%>
  <% elsif -%>
  <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  hostgroups all,<%= n.os %>
  <% else -%>
  hostgroups <%= n.run_list.roles.to_a.join(",") %>,<%= n['os'] %>
  <% end -%>
  <% end -%>
}

<% end -%>

<% unless @unmanaged_hosts.nil? -%>
<% @unmanaged_hosts.each do |n| -%>
define host {
  use server
  address <%= n['address'] %>
  host_name <%= n['id'] %>
  hostgroups <%= n['hostgroups'].join(",") %>
  notifications_enabled <%= n['notifications'] %>
}
<% end -%>
<% end -%>
# Host definitions
#
# Autogenerated by Chef.

<% @nodes.each do |n| -%>
define host {
  use server
  address <%= (!n['cloud'].nil? && n['cloud'] != node['cloud']) ? n['cloud']['public_ipv4'] : n['ipaddress'] %>
  host_name <%= n['hostname'] %>
  <% if node['nagios']['multi_environment_monitoring'] -%>
  <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  hostgroups all,<%= n.os %>,<%= n.chef_environment %>
  <% else -%>
  hostgroups <%= (n.run_list.roles.to_a & @hostgroups).join(",") %>,<%= n.os %>,<%= n.chef_environment %>
  <% end -%>
  <% elsif -%>
  <% if n.run_list.roles.nil? || n.run_list.roles.length == 0 -%>
  hostgroups all,<%= n.os %>
  <% else -%>
  hostgroups <%= (n.run_list.roles.to_a & @hostgroups).join(",") %>,<%= n['os'] %>
  <% end -%>
  <% end -%>
}

<% end -%>

<% unless @unmanaged_hosts.nil? -%>
<% @unmanaged_hosts.each do |n| -%>
define host {
  use server
  address <%= n['address'] %>
  host_name <%= n['id'] %>
  hostgroups <%= n['hostgroups'].join(",") %>
  notifications_enabled <%= n['notifications'] %>
}
<% end -%>
<% end -%>
Add the check to make sure the roles all exist even if we're not using multi_environment monitoring
Add the check to make sure the roles all exist even if we're not using multi_environment monitoring


Former-commit-id: c4a94afb61aa5d767d3a29bbaed717799f3a4ef8 [formerly 7b3dc0cd48fe7aad8833984e31dd7ae17e3425f3] [formerly 2ffc8c370fcc91a98ac4559c7e6c9b9067c1c1d4 [formerly aef9c98e6af175df19de4286c7aa1e7ce697a512 [formerly 2bb65db0d3b8ee3a4cb53c379f312414f317c220]]]
Former-commit-id: 2f73ace33aaadc5cba08fabbb417e09030f4a7aa [formerly 7b0dd82eb115b1d8e6553eb0ac0229a030784ce7]
Former-commit-id: 128a3fb27309fd29905cc75abc7034094a39d00a
Former-commit-id: 6f72cc4b9c63a970f33f6eb3881cbefbdb5fdb83