Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Host definitions
- #
- # Autogenerated by Chef.
- define host {
- use server
- address <%= node['ipaddress'] %>
- host_name <%= node[node['nagios']['host_name_attribute']] %>
- hostgroups <%= node['nagios']['server_role'] %>,<%= node['os'] %>
- }
- <% @nodes.each do |n| -%>
- <% unless n.name == node.name -%>
- define host {
- use server
- <%
- if node['cloud'].nil? && !n['cloud'].nil?
- ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
- elsif !node['cloud'].nil? && n['cloud']['provider'] != node['cloud']['provider']
- ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
- else
- ip = n['ipaddress']
- end %>
- address <%= ip %>
- host_name <%= n[node['nagios']['host_name_attribute']] %>
- <% 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 -%>
- <% 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 -%>
Advertisement
Add Comment
Please, Sign In to add comment