Repository navigation
Description
Description
While writing a custom renderer, placed into _renderers (which is next to _grains, _modules, etc.) inside a git repository, I found that, after synchronizing the repository to the Salt master, a saltutil.sync_all synchronizes the renderer to the minion (Why? It's only needed on the master anyway.), but doesn't load it from there (as opposed to what the documentation says). Also tried putting it into a local file_root on the master, but got the same result.
The master log always shows a message like this:
2022-10-03 15:14:38,655 [salt.template :240 ][ERROR ][78661] The renderer "yaml|custom" is not available
It is found and executed only if I put it into /usr/lib/python3/dist-packages/salt/renderers and restart salt-master.service.
Setup
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (LXC)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
- Add custom renderer into
_renderersdirectory in either a git repository or local file_root, to have it accessible viasalt://_renderers - Use it to render pillar data
Expected behavior
Custom renderer should be loaded from said location
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3004.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.8.1
docker-py: Not Installed
gitdb: 4.0.5
gitpython: 3.1.14
Jinja2: 2.11.3
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.0
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: 3.9.7
pygit2: Not Installed
Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
python-gnupg: 0.4.6
PyYAML: 5.3.1
PyZMQ: 20.0.0
smmap: 4.0.0
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: debian 11 bullseye
locale: utf-8
machine: x86_64
release: 5.10.0-17-amd64
system: Linux
version: Debian GNU/Linux 11 bullseye
Activity
OrangeDog commentedon Oct 3, 2022
Most rendering happens on the minion. Only pillars are the usual exception.
heini commentedon Oct 3, 2022
Ah, OK.
OrangeDog commentedon Oct 3, 2022
What is the code for the renderer and how did you attempt to use it?
Is there any additional debug logging?
heini commentedon Oct 3, 2022
There's no additional debug logging. It's only the line shown above.
The code is the beginning of a renderer to decrypt pillar strings as produced by hiera-eyaml:
with test.sls looking like so:
which resolves to
# salt-call pillar.get plain local: ---------- text: sometextOrangeDog commentedon Oct 3, 2022
You set the minion log level to DEBUG and "Loading renderer: decrypt..." was never logged?
This code is in a file at
salt://_renderers/custom.py?heini commentedon Oct 3, 2022
Yes, that's correct. It's only executed if stored in
grains['saltpath']/rendererson the master. Then, and only then, it is working as expected and I see the above message (in the master log).OrangeDog commentedon Oct 3, 2022
So you are trying to run it on the master (i.e. for pillar), not on minions?
Did you do
salt-run saltutil.sync_all? That syncs custom modules to the master, not the minions.A restart may also be needed after that, I am unsure.
heini commentedon Oct 3, 2022
No, I also tried to run it on minions, of course. But the outcome is the same. As written above, it gets synchronized, but it is never executed. Also in case of
salt myminion saltutil.sync_all && salt myminion pillar.get plainit's only executed after copying it tograins['saltpath']/rendererson the master and restarting it.OrangeDog commentedon Oct 3, 2022
If you're trying to use it in pillar then it runs on the master, not the minion.
Therefore you need to sync it to the master, not the minion.
That's why it works when you manually copy it to the master's source tree, not the minion's.
heini commentedon Oct 3, 2022
OK, understood. Indeed, I removed it from the
grains['saltpath']/renderersdirectory again, restarted the master, did asalt-run saltutil.sync_alland it's working now.Maybe worth mentioning in the documentation?
Anyway, thanks a lot for your quick help!