You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bugbroken, incorrect, or confusing behaviorCorerelates to code central or existential to SaltGrainsP3Priority 3severity-medium3rd level, incorrect or bad functionality, confusing and lacks a work aroundstale
I want to set a grain in one state, reload_grains: True, do some stuff in the middle, and then change the same grain in another state. I use some jinja below to reload the grain, and set a variable in the state. But the rendering of the code before execution checks to see if the grain exists, doesn't find it, and throws an error.
So a grain set from within the state doesn't apply. I tried to initialize the grain with _grains, but with the current precedence, it always overrides my in state grains. The current precedence is inconsistent between core grains and custom grains.
Sane precedence:
_grains become before /etc/salt/grains instead of after
Documented precedence:
https://docs.saltstack.com/en/latest/topics/targeting/grains.html#precedence
Core grains.
Custom grains in /etc/salt/grains.
Custom grains in /etc/salt/minion.
Custom grain modules in _grains directory, synced to minions.
Error:
/var/cache/salt/minion/files/base/baseline/map.jinja(50):
---
[...]
'mirror': 'mirror.foo.com'
},
}
, grain="mirror", merge=salt['pillar.get']('baseline')) %}
{% do defaults.baseline.update(mirror_map) %} <======================
{% set settings = salt['pillar.get']('baseline', default=defaults.baseline, merge=True) %}
---
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 368, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 1, in top-level template code
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 1013, in make_module
return TemplateModule(self, self.new_context(vars, shared, locals))
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 1070, in __init__
self._body_stream = list(template.root_render_func(context))
File "/var/cache/salt/minion/files/base/baseline/map.jinja", line 50, in top-level template code
{% do defaults.baseline.update(mirror_map) %}
TypeError: 'NoneType' object is not iterable
The text was updated successfully, but these errors were encountered:
jfindlay
added
Bug
broken, incorrect, or confusing behavior
severity-medium
3rd level, incorrect or bad functionality, confusing and lacks a work around
Core
relates to code central or existential to Salt
P3
Priority 3
Grains
labels
Nov 25, 2015
Seems like due to restructuring the precedence of grains documentation has been moved from the 'targeting' page to https://docs.saltstack.com/en/latest/topics/grains/#precedence since this issue was opened. As @jfindlay mentioned, the documentation issue was also addressed in #27005 which was resolved then by #27706 - at least for the 2015.5 release.
I experienced in salt 2016.3.3 (Boron) that the last two instances in the precedence list are not correct:
Custom grains in /etc/salt/minion.
Custom grain modules in _grains directory, synced to minions.
File-based grains in /etc/salt/minion definitely override grain modules in the _grains module. So for me it seems the precedence section should be reverted to a067e6c. Should I open another issue or is this related enough?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Bugbroken, incorrect, or confusing behaviorCorerelates to code central or existential to SaltGrainsP3Priority 3severity-medium3rd level, incorrect or bad functionality, confusing and lacks a work aroundstale
I want to set a grain in one state, reload_grains: True, do some stuff in the middle, and then change the same grain in another state. I use some jinja below to reload the grain, and set a variable in the state. But the rendering of the code before execution checks to see if the grain exists, doesn't find it, and throws an error.
So a grain set from within the state doesn't apply. I tried to initialize the grain with _grains, but with the current precedence, it always overrides my in state grains. The current precedence is inconsistent between core grains and custom grains.
Sane precedence:
Documented precedence:
Error:
Jinja:
The text was updated successfully, but these errors were encountered: