[icinga-checkins] icinga.org: chef-icinga2/master: Be more conservative with Chef attributes

git at icinga.org git at icinga.org
Tue Jul 19 18:01:46 CEST 2016


Module: chef-icinga2
Branch: master
Commit: 204aeef7781380a0b3e0b38ccf0c5cfdee978007
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=204aeef7781380a0b3e0b38ccf0c5cfdee978007

Author: Henry Finucane <henry.finucane at illumio.com>
Date:   Thu Mar 24 11:10:57 2016 -0700

Be more conservative with Chef attributes

While '-' literals are valid in attribute keys, they are not valid with
'dot' notation.

Plug in icinga_format so that differences between Ruby and the Icinga
configuration language can be papered over comprehensively.

This is the only template I needed to touch for my use case, but there
are others that seem like they could use the same treatment.

---

 templates/default/object.environment.conf.erb |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/templates/default/object.environment.conf.erb b/templates/default/object.environment.conf.erb
index 5bd8ef4..099e554 100644
--- a/templates/default/object.environment.conf.erb
+++ b/templates/default/object.environment.conf.erb
@@ -89,19 +89,19 @@ object Host <%= node_hash['fqdn'].inspect %> {
   <% if var && value && value.is_a?(Hash) -%>
   <% value.each do |a, v|-%>
   <% if a && v && v.is_a?(Hash) && !v.empty?-%>
-  vars.<%= var -%><%= [a].inspect -%> = {
+  vars["<%= var -%>"][<%= a.inspect -%>] = {
   <% v.each do |a1, v1|%>
   <% if a1 && v1 %>
-  <%= a1 -%> = <%= v1.inspect %>
+  "<%= a1 -%>" = <%= icinga_format(v1) %>
   <% end -%>
   <% end -%>
   }
   <% else -%>
-  vars.<%= var -%><%= [a].inspect -%> = <%= v.inspect %>
+  vars["<%= var -%>"][<%= a.inspect -%>] = <%= icinga_format(v) %>
   <% end -%>
   <% end -%>
   <% elsif var && value -%>
-  vars.<%= var -%> = <%= value.inspect %>
+  vars["<%= var -%>"] = <%= icinga_format(value) %>
   <% end -%>
   <% end -%>
   <% end -%>



More information about the icinga-checkins mailing list