Hello,
I have a salt pillar problem and I do not see what I am doing wrong. Hope anyone can give me a hint
I defined a pillar "diskusage.sls" (included in /srv/pillar/base/top.sls ):
diskusage:
default:
'/': 90
'/var': 90
'/boot': 90
myhost:
'/': 50
'/var': 80
'/boot': 80
'/mnt': 30
Then I defined a "beacons.sls" file with jinja code to check how full the relevant minions filesystems are. Via jinja I want to either insert filesystems for the current host if the hostname is found in the diskusage pillar or to use the defined default values from the pillar. My beacons.sls now looks like this:
{% set fsdefault=salt['pillar.get']('diskusage:default') %}
beacons:
diskusage:
{% for fs, percent in pillar.get('diskusage:' ~ grains['host'], default=fsdefault).items() %}
- {{ fs }}: {{ percent }}
{% endfor %}
- onchangeonly: True
- interval: 30 # seconds
The problem is that a call
# salt 'anyhost*' state.apply
results in an error:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'beacons' failed. Please see master log for details.
In the masters log I see:
2018-07-31 14:15:56,717 [salt.utils.templates:180 ][ERROR ][20621] Rendering exception occurred
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 169, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 390, in render_jinja_tmpl
buf=tmplstr)
SaltRenderError: Jinja variable 'unicode object' has no attribute 'items'
2018-07-31 14:15:56,718 [salt.pillar :732 ][CRITICAL][20621] Rendering SLS 'beacons' failed, render error:
Jinja variable 'unicode object' has no attribute 'items'
2018-07-31 14:15:56,749 [salt.pillar :1005][CRITICAL][20621] Pillar render error: Rendering SLS 'beacons' failed. Please see master log for details.
However a call on salt master:
# salt-call slsutil.renderer /srv/pillar/base/beacons.sls 'jinja'
works fine and returns:
local:
----------
beacons:
----------
diskusage:
|_
----------
/boot:
90
|_
----------
/var:
90
|_
----------
/:
90
|_
----------
onchangeonly:
True
|_
----------
interval:
30
Now I really have no idea whats going wrong here. Can anyone help?
Thanks
Rainer