how to verify salt master config / add custom module
Hi list, i want to add a custom salt module "pwgen" but always get this error: salt.exceptions.SaltRenderError: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'pwgen.get_pw' I tried adding it using "module_dirs" in a custom config file: echo 'module_dirs: [/opt/passdb/pwgen-salt-module]' > /etc/salt/master.d/mycustom.conf I tried using "extension_modules" directly in /etc/salt/master: echo 'extension_modules: /opt/passdb/pwgen-salt-module' > /etc/salt/master I also tried with and without subdirectory "modules" within " /opt/passdb/pwgen-salt-module" After adding to config I restarted uyuni (spacewalk-service stop/start) and also salt (systemctl restart salt-master). Where is my error? In Salt config or in my module (python) code? How can i verify, that salt master accepts my additional config and reads/adds my custom module (/opt/passdb/pwgen-salt-module/pwgen.py)? BR Heiner
Hi Heiner, I think what you just need is adding your custom Salt module file to "/srv/salt/_modules/" in your Uyuni server, and then synchronize the custom modules with your minions (so they have it available to execute). You don't really need to add any extra configuration to Salt. So, you place the module at "/srv/salt/_modules/", and then: # salt MINION saltutil.sync_modules You should see your custom module is been synced into the minion. Then, you should be able to call your custom module. # salt MINION pwgen.get_pw This is described in Salt documentation: https://docs.saltproject.io/en/3004/ref/modules/index.html Hth! Pablo El 17/1/23 a las 14:34, Heiner Wulfhorst escribió:
Hi list,
i want to add a custom salt module "pwgen" but always get this error: salt.exceptions.SaltRenderError: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'pwgen.get_pw'
I tried adding it using "module_dirs" in a custom config file: |echo '||module_dirs: [/opt/passdb/pwgen-salt-module]' > /etc/salt/master.d/mycustom.conf|
I tried using "extension_modules" directly in /etc/salt/master: |echo '||extension_modules: /opt/passdb/pwgen-salt-module' > /etc/salt/master|
I also tried with and without subdirectory "modules" within "|/opt/passdb/pwgen-salt-module|"
After adding to config I restarted uyuni (spacewalk-service stop/start) and also salt (systemctl restart salt-master).
Where is my error? In Salt config or in my module (python) code? How can i verify, that salt master accepts my additional config and reads/adds my custom module (/opt/passdb/pwgen-salt-module/pwgen.py)?
BR Heiner
-- Pablo Suárez Hernández<psuarezhernandez@suse.de> SUSE Manager Development Team SUSE Software Solutions -https://www.suse.com/
Hi Pablo, thanks for your help! In fact putting my module into /etc/salt/master.d/mycustom.conf was fine, i was able to verify its state by checking /var/log/salt/master and finding errors regarding code in my module. Unfortunately my module is not listed in salt <minion> sys.list_modules or salt-call --local sys.list_modules, but i think that is a minor issue. Thanks, Heiner
participants (3)
-
Heiner W.
-
Heiner Wulfhorst
-
Pablo Suárez Hernández