Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save javierbertoli/255928c6e2613d86d836d71948d6c057 to your computer and use it in GitHub Desktop.
Save javierbertoli/255928c6e2613d86d836d71948d6c057 to your computer and use it in GitHub Desktop.
Salt error running against any of the saltstack-formulas `master` images,
Any of the formulas that use `grains[]` in the `*yaml` files fail, ie rspamd-formula or docker-formula
Ie, in the rspamd-formula, try it with
kitchen test --destroy=never default-debian-10-master-py3 --log-level=debug 2>&1|tee /tmp/output
Error:
...
[INFO ] Fetching file from saltenv 'base', ** done ** 'rspamd/osfamilymap.yaml'
[ERROR ] Rendering exception occurred
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 497, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1289, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 924, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 6, in top-level template code
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1394, in make_module
return TemplateModule(self, ctx)
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1524, in __init__
body_stream = list(template.root_render_func(context)) # type: ignore
File "/tmp/kitchen/var/cache/salt/minion/files/base/rspamd/map.jinja", line 8, in top-level template code
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1394, in make_module
return TemplateModule(self, ctx)
File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1524, in __init__
body_stream = list(template.root_render_func(context)) # type: ignore
File "/tmp/kitchen/var/cache/salt/minion/files/base/rspamd/osfamilymap.yaml", line 7, in top-level template code
name: deb http://rspamd.com/apt-stable/ {{ grains['oscodename'] }} main
File "/usr/local/lib/python3.7/dist-packages/jinja2/sandbox.py", line 303, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'grains' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 261, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 504, in render_jinja_tmpl
raise SaltRenderError("Jinja variable {}{}".format(exc, out), buf=tmplstr)
salt.exceptions.SaltRenderError: Jinja variable 'grains' is undefined
/tmp/kitchen/var/cache/salt/minion/files/base/rspamd/osfamilymap.yaml(7):
---
[...]
# vim: ft=yaml
---
Debian:
repo:
enabled: true
name: deb http://rspamd.com/apt-stable/ {{ grains['oscodename'] }} main <======================
file: /etc/apt/sources.list.d/rspamd.list
key_url: https://rspamd.com/apt-stable/gpg.key
# Arch has no osmajorrelease and this piece of code makes it fail
{% if grains['os']|lower != 'arch' %}
[...]
---
[CRITICAL] Rendering SLS 'base:rspamd._mapdata' failed: Jinja variable 'grains' is undefined
/tmp/kitchen/var/cache/salt/minion/files/base/rspamd/osfamilymap.yaml(7):
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment