Apologies for the wall of text approaching.
a bit further:
# salt-run pillar.show_top minion -l debug
[DEBUG ] pillarenv 'base' not found in the configured pillar environments
Indeed we have no base environment, and this minion has another saltenv defined; if I pass saltenv=goodenvname then I see the desired top output for this particular environment
If I use another saltenv pillar top.sls with the old code, then it fails with the same error:
[ERROR ] Pillar rendering failed for minion minionname
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/utils/templates.py", line 502, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 25, in top-level template code
File "/usr/lib/python3.6/site-packages/jinja2/sandbox.py", line 456, in call
return __self.format_string(fmt, args, kwargs, __obj)
File "/usr/lib/python3.6/site-packages/jinja2/sandbox.py", line 449, in format_string
rv = formatter.vformat(s, args, kwargs)
File "/usr/lib64/python3.6/string.py", line 194, in vformat
result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
File "/usr/lib64/python3.6/string.py", line 247, in _vformat
result.append(self.format_field(obj, format_spec))
File "/usr/lib64/python3.6/string.py", line 264, in format_field
return format(value, format_spec)
jinja2.exceptions.UndefinedError: dict_keys object has no element 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/pillar/__init__.py", line 684, in get_tops
_pillar_rend=True,
File "/usr/lib/python3.6/site-packages/salt/template.py", line 99, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/renderers/jinja.py", line 75, in render
**kws
File "/usr/lib/python3.6/site-packages/salt/utils/templates.py", line 261, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/lib/python3.6/site-packages/salt/utils/templates.py", line 509, in render_jinja_tmpl
raise SaltRenderError("Jinja variable {}{}".format(exc, out), buf=tmplstr)
salt.exceptions.SaltRenderError: Jinja variable dict_keys object has no element 0
[DEBUG ] Sending event: tag = salt/run/20220221203727857405/progress; data = {'data': ['Rendering Primary Top file failed, render error:\nJinja variable dict_keys object has no element 0'], 'outputter': 'nested', '_stamp': '2022-02-21T20:37:30.375981'}
[DEBUG ] LazyLoaded nested.output
event:
----------
_stamp:
2022-02-21T20:37:30.375981
data:
- Rendering Primary Top file failed, render error:
Jinja variable dict_keys object has no element 0
outputter:
nested
suffix:
progress
[DEBUG ] LazyLoaded local_cache.prep_jid
[DEBUG ] Sending event: tag = salt/run/20220221203727857405/ret; data = {'fun': 'runner.pillar.show_top', 'jid': '20220221203727857405', 'user': 'sudo_xxxx@sddl', 'fun_args': ['minionname', {'saltenv': 'othername'}], '_stamp': '2022-02-21T20:37:30.385273', 'return': ['Rendering Primary Top file failed, render error:\nJinja variable dict_keys object has no element 0'], 'success': True}
[DEBUG ] LazyLoaded nested.output
- Rendering Primary Top file failed, render error:
Jinja variable dict_keys object has no element 0
[INFO ] Runner completed: 20220221203727857405
[DEBUG ] Closing IPCMessageClient instance
[DEBUG ] Runner return: ['Rendering Primary Top file failed, render error:\nJinja variable dict_keys object has no element 0']
the master itself is set as minion with another saltenv name, not base.
So where is this saltenv coming from?