question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom modules synced after pillar render

See original GitHub issue

Description of Issue

Custom modules, are synced either via manual saltutil.sync_all or state.highstate run.
During highstate run they are synced after the pillar renders. However the highstates pillar may already be using them and thus will fail.

1.Is it something that may be relaxed to allow usage of custom modules during the very first highstate run?

2.Why does the pillar render before the sync_all? To me It seems that first syncing the modules then rendering is more natural way.

This is a bit unwieldy, especially when using salt provisioner for Vagrant

Please see the below setup instruction.

Setup

Any setup with custom module: e.g: _sdb/kdbx.py

Steps to Reproduce Issue

  1. Clean Salt install (masterless will do)
  2. Custom module in _sdb (in State Tree Root)
  3. Pillar data that already uses this module: somepillar.sls
key: {{ salt['sdb.get']("sdb://kdbx/secret/path") }}
  1. Run state.highstate

The 4. will fail with:

[CRITICAL] Rendering SLS 'REDACTED' failed, render error:                                                                                                                                                                                                                                                                    
Jinja error: 'kdbx.get'                                                                                                                                                                                                                                                                                                      
Traceback (most recent call last):                                                                                                                                                                                                                                                                                           
  File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 394, in render_jinja_tmpl                                                                                                                                                                                                                              
    output = template.render(**decoded_context)                                                                                                                                                                                                                                                                              
  File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 1008, in render                                                                                                              
    return self.environment.handle_exception(exc_info, True)                                                                                
  File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 780, in handle_exception                                                    
    reraise(exc_type, exc_value, tb)                                                                                                                                                        
  File "/usr/local/lib/python3.5/dist-packages/jinja2/_compat.py", line 37, in reraise                                                                                                                                  
    raise value.with_traceback(tb)                                                                                                        
  File "<template>", line 122, in top-level template code                                                                                                                                                                                                                                                                    
  File "/usr/lib/python3/dist-packages/salt/modules/sdb.py", line 28, in get                                                                                                                                                                                                                                                 
    return salt.utils.sdb.sdb_get(uri, __opts__, __utils__)                                                                                                                                                                                                                                                                  
  File "/usr/lib/python3/dist-packages/salt/utils/sdb.py", line 46, in sdb_get                                                                                                                                                                                                                                               
    return loaded_db[fun](query, profile=profile)                                                                                                                            
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1208, in __getitem__                                                                   
    func = super(LazyLoader, self).__getitem__(item)                                                                                                                                                                                                                            
  File "/usr/lib/python3/dist-packages/salt/utils/lazy.py", line 108, in __getitem__                                                                  
    raise KeyError(key)                                                                                                                                                  
KeyError: 'kdbx.get'                   

Versions Report

Salt Version:
           Salt: 2019.2.2
 
Dependency Versions:
           cffi: 1.13.2
       cherrypy: 18.4.0
       dateutil: 2.8.1
      docker-py: 1.10.6
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10.3
        libgit2: 0.28.2
        libnacl: Not Installed
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 3.9.4
   pycryptodome: Not Installed
         pygit2: 0.28.2
         Python: 3.5.3 (default, Sep 27 2018, 17:25:39)
   python-gnupg: Not Installed
         PyYAML: 5.1.2
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.1 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-8-amd64
         system: Linux
        version: debian 9.1 

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kiemliczcommented, Jul 9, 2021

Originally I wanted to use this in kitchen-salt, because the: https://github.com/saltstack/kitchen-salt/issues/295 was open back then
However the kitchen-salt introduced the pre_salt_command which is a workaround for me

I’m not aware of any workaround for this issue here, other than manually running sync_all prior to highstate - absolutely terrible…

0reactions
jkenn99commented, Jul 8, 2021

@kiemlicz have you come up with any workarounds for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Renderers - Salt Project Documentation
Custom renderers should be placed within salt://_renderers/ , so that they can be synced to minions. They are synced when any of the...
Read more >
How do I load custom ext_pillar modules from git? #50949
Using salt-run saltutil.sync_pillar will sync custom ext_pillar modules from salt://_pillar . 1
Read more >
Custom Saltstack Python module function accesible in pillar ...
I am having some data loaded inside of my pillar file configuration.sls which is using Jinja templating.
Read more >
Basics of rendering and exporting in After Effects CC
Learn how to render and export in After Effects using the Render Queue panel and Media Encoder and what are the supported output...
Read more >
SaltStack: Grains, Pillars, Targeting and Render Systems
Grains directory, synced to minions. You can set up custom grains using either of the following methods. Minion (the easiest and preferred ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found