What can be wrong here? It work ok, when i try to hardcode state
State:
{% for service, args in pillar.get('xml',{}).items() %}
{{ service }}:
ensure_value_true:
xml.value_present:
- name: {{ args['name'] }}
- xpath: {{ args['xpath'] }}
- value: {{ args['value'] }}
{% endfor %}
Pillar:
xml:
MqHostName:
value: 'mq.ext'
xpath: './/MqHostName'
name: 'C:\\PFEI\ExternalMqService\Configs\MqSettings.Ext.xml'
MqPort:
value: '2911'
xpath: 'MqPort'
name: 'C:\\PFEI\ExternalMqService\Configs\MqSettings.Ext.xml'
Error:
Data failed to compile:
----------
State 'MqHostName' in SLS 'xml' is not formed as a list
Try the following command to troubleshoot just the Jinja statements without evaluating the resulting Yaml:
salt MINION slsutil.renderer default_renderer=jinja path=salt://xml.sls
salt MINION slsutil.renderer default_renderer=jinja path=salt://xml.sls
Nothing usefull(
[root@ ~]# salt '*mq' slsutil.renderer default_renderer=jinja path=salt://xml.sls
minion-mq:
-----------
[root@ ~]#
Okey i found error, but got new one:
----------
Rendering SLS 'base:xml' failed: while constructing a mapping
in "<unicode string>", line 2, column 1
found conflicting ID 'ensure_value_true'
in "<unicode string>", line 9, column 1
State:
{% for service, args in pillar.get('xml',{}).items() %}
ensure_value_true:
xml.value_present:
- name: {{ args['name'] }}
- xpath: {{ args['xpath'] }}
- value: {{ args['value'] }}
{% endfor %}
Okey, after comile it seems like:
ensure_value_true:
xml.value_present:
- name: C:\\Ext.xml
- xpath: .//MqHost
- value: mq.ext
ensure_value_true:
xml.value_present:
- name: C:\\Ext.xml
- xpath: .//MqPort
- value: 1489
Seems i need to give UID before ensure value, how can i make it?
Good @Morozzko so this new error is just minor.
Use state name ensure_value_true_{{ service }}: to avoid ID name collisions inside for loop.
This is not salt issue just Jinja convention.
Good @Morozzko so this new error is just minor.
Use state nameensure_value_true_{{ service }}:to avoid ID name collisions inside for loop.
This is not salt issue just Jinja convention.
thx, make my morning iced