Do not force converting 'params' values to string
Patch with replacing "u'" to "'" forces converting all 'params:'
values to string. This lead to converting dicts to
an OrderedDict object that become a string when Salt stores
the rendered file:
1. Source data for reclass.storage:
parameters:
reclass:
storage:
node:
infra_kvm_node01:
params:
example_dict:
first_key: 1
second_key: 2
example_unicode: u'string'
2. Current result, 'reclass' reads 'example_dict' value
as a string "OrderedDict([..." and pass it to Salt pillar:
parameters:
_param:
example_dict: OrderedDict([('first_key', 1), ('second_key', 2)])
example_unicode: 'string'
3. This patch apply 'replace' only for string objects, keeping other
objects as is, so the dict value will work fine:
parameters:
_param:
example_dict: {'first_key': 1, 'second_key': 2}
example_unicode: 'string'
Change-Id: Ib11e5a14168941d528d7d506401813e2fb9b8ead
diff --git a/reclass/files/node.yml b/reclass/files/node.yml
index 25a190e..9b9c3c9 100644
--- a/reclass/files/node.yml
+++ b/reclass/files/node.yml
@@ -6,10 +6,18 @@
{%- if node.params is defined or extra_params|length > 0 %}
_param:
{%- for param_name, param_value in node.params.iteritems() %}
+ {%- if param_value is not string %}
+ {{ param_name }}: {{ param_value }}
+ {%- else %}
{{ param_name }}: {{ param_value|replace("u'", "'") }}
+ {%- endif %}
{%- endfor %}
{%- for param_name, param_value in extra_params.iteritems() %}
+ {%- if param_value is not string %}
+ {{ param_name }}: {{ param_value }}
+ {%- else %}
{{ param_name }}: {{ param_value|replace("u'", "'") }}
+ {%- endif %}
{%- endfor %}
{%- endif %}
{{ node.get('kernel', 'linux') }}: