From cc424eff028b4703c499567f1e9a4f54120eac5d Mon Sep 17 00:00:00 2001 From: Danial Pearce Date: Sun, 16 Sep 2012 06:24:39 +1000 Subject: [PATCH] Allow alias value to be an array. COOK-1660 --- README.md | 3 +++ templates/default/aliases.erb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e81f9b..88336e8 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,9 @@ template to the `templates/default` or to the appropriate platform+version directory per the File Specificity rules for templates. Then specify a hash of aliases for the `node['postfix']['aliases']` attribute. +Arrays are supported as alias values, since postfix supports +comma separated values per alias, simply specify your alias +as an array to use this handy feature. http://wiki.opscode.com/display/chef/Templates#Templates-TemplateLocationSpecificity diff --git a/templates/default/aliases.erb b/templates/default/aliases.erb index 9a54578..182cbae 100644 --- a/templates/default/aliases.erb +++ b/templates/default/aliases.erb @@ -7,5 +7,5 @@ postmaster: root <% node['postfix']['aliases'].each do |name, value| %> -<%= name %>: "<%= value %>" +<%= name %>: <%= [value].flatten.map{|x| %Q("#{x}")}.join(', ') %> <% end unless node['postfix']['aliases'].nil? %>