Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/254327
Change subject: redis::instance: support hash configuration values ...................................................................... redis::instance: support hash configuration values With this patch, a redis instance instantiated as: redis::instance { 6379: settings => { rename_command => { FLUSHALL => '', CONFIG => '', FLUSHDB => '', } } } ..would result in a configuration file with a block that looks like this: rename-command FLUSHALL "" rename-command CONFIG "" rename-command FLUSHDB "" Change-Id: I867f136add813b9d24970b2d9f803205fee5fb2b --- M modules/redis/templates/instance.conf.erb 1 file changed, 21 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/27/254327/1 diff --git a/modules/redis/templates/instance.conf.erb b/modules/redis/templates/instance.conf.erb index 169e4d5..6a432b9 100644 --- a/modules/redis/templates/instance.conf.erb +++ b/modules/redis/templates/instance.conf.erb @@ -5,15 +5,28 @@ # Instance-specific settings <%= + def redis_config_item(key, value) + Array(value).flatten.map { |item| + case item + when TrueClass then 'yes' + when FalseClass then 'no' + else item + end + }.unshift(key.tr '_', '-').join(' ') + end + @defaults.merge(@settings).select { |k,v| !v.empty? and v.to_s != 'undef' - }.map { |k,v| - Array(v).flatten.map { |item| - case item - when TrueClass then 'yes' - when FalseClass then 'no' - else v - end - }.unshift(k.tr '_', '-').join(' ') + }.reduce([]) { |lines,kv| + k, v = *kv + + case v + when Hash + v.each { |v1,v2| lines.push redis_config_item(k, [v1, v2]) } + else + lines.push redis_config_item(k, v) + end + + lines }.sort.join("\n") %> -- To view, visit https://gerrit.wikimedia.org/r/254327 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I867f136add813b9d24970b2d9f803205fee5fb2b Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ori.livneh <o...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits