]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/libraries/expand.rb
Add a bunch more cookbooks
[chef.git] / cookbooks / munin / libraries / expand.rb
diff --git a/cookbooks/munin/libraries/expand.rb b/cookbooks/munin/libraries/expand.rb
new file mode 100644 (file)
index 0000000..9269761
--- /dev/null
@@ -0,0 +1,13 @@
+class Chef
+  class Munin
+    def self.expand(template, nodes)
+      nodes.map do |node| 
+        if node.kind_of?(Hash)
+          template.gsub(/%%([^%]+)%%/) { node[$1.to_sym] }
+        else
+          template.gsub("%%", node)
+        end
+      end.join(" ")
+    end
+  end 
+end