diff options
Diffstat (limited to 'mcp/patches/0014-reclass.storage.node-Merge-duplicate-nodes.patch')
-rw-r--r-- | mcp/patches/0014-reclass.storage.node-Merge-duplicate-nodes.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/mcp/patches/0014-reclass.storage.node-Merge-duplicate-nodes.patch b/mcp/patches/0014-reclass.storage.node-Merge-duplicate-nodes.patch new file mode 100644 index 000000000..25159bc4a --- /dev/null +++ b/mcp/patches/0014-reclass.storage.node-Merge-duplicate-nodes.patch @@ -0,0 +1,44 @@ +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +: Copyright (c) 2017 Mirantis Inc., Enea AB and others. +: +: All rights reserved. This program and the accompanying materials +: are made available under the terms of the Apache License, Version 2.0 +: which accompanies this distribution, and is available at +: http://www.apache.org/licenses/LICENSE-2.0 +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Sun, 03 Dec 2017 22:03:01 +0200 +Subject: [PATCH] reclass.storage.node: Merge duplicate nodes + +Reclass does not support duplicate nodes in top pillar, so merge all +nodes with the same name into a single node, inheriting classes from +all instances. + +This allows using multiple "system.reclass.storage.system.*_cluster" +classes for the same node, based on re-using the name (hostname). + +NOTE: defaults.merge module does not merge lists (e.g. for classes), +so handle that case separately. + +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +--- + +diff --git a/reclass/storage/node.sls b/reclass/storage/node.sls +--- a/reclass/storage/node.sls ++++ b/reclass/storage/node.sls +@@ -1,7 +1,15 @@ + {%- from "reclass/map.jinja" import storage with context %} + {%- if storage.enabled %} + ++{%- set storage_by_name = {} %} + {%- for node_name, node in storage.get('node', {}).iteritems() %} ++{%- set new_node_name = node.get('name', node_name) %} ++{%- set new_node = storage_by_name.get(new_node_name, {'classes': []}) %} ++{%- do salt['defaults.merge'](node, {'classes': new_node.classes + node.classes}) %} ++{%- do salt['defaults.merge'](storage_by_name, {new_node_name: node}) %} ++{%- endfor %} ++ ++{%- for node_name, node in storage_by_name.iteritems() %} + + {%- if node.repeat is defined %} + |