Skip to content

Instantly share code, notes, and snippets.

@maplebed
Created January 30, 2013 01:43
Show Gist options
  • Save maplebed/4669873 to your computer and use it in GitHub Desktop.
Save maplebed/4669873 to your computer and use it in GitHub Desktop.
possible patch for COOK-2257?
diff --git a/templates/default/hosts.cfg.erb b/templates/default/hosts.cfg.erb
index 3868fba..5f0f20c 100644
--- a/templates/default/hosts.cfg.erb
+++ b/templates/default/hosts.cfg.erb
@@ -24,7 +24,12 @@ define host {
ip = n['cloud']['public_ipv4']
else
ip = n['ipaddress']
- end %>
+ end
+ if ip =~ /^ *$/
+ # ERROR! ip address shouldn't be empty. but to avoid a nagios syntax error, replace with 127.0.0.1
+ # can we spew this into the chef log as a non-fatal WARNING from within the template?
+ ip = "127.0.0.1"
+ end%>
address <%= ip %>
host_name <%= n[node['nagios']['host_name_attribute']] %>
<% if node['nagios']['multi_environment_monitoring'] -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment