Saltstack patching
From wikinotes
You can patch specific problem versions of saltstack if you encounter a bug in saltstack itself.
Patch Specific Salt-Minion Versions
These instructions let you patch a salt module/state for a specific range of salt-minion versions, and fall back on the installed version if not a part of that version range.
Determine versions of salt being used
sudo salt '*' test.version sudo salt-run survey.hash '*' test.version # (more concise)Copy problematic salt module or state to your custom modules/states dir.
Rename it so that it does not clash with the existing module.cp /usr/lib/python3.7/site-packages/salt/modules/virtualenv_mod.py \ /home/salt/saltstack/states/_modules/virtualenv_mod_override.py # <-- note 'override' suffixRewrite the
__virtual__()
function.
#: name of module. ex: ``salt-call module.func`` __virtualname__ = 'virtualenv' def __virtual__(): """ returns name of module (and uses it) if version of salt-minion version does not start with 2019 or 3000. """ broken_versions = ('2019', '3000') if __grains__['saltversion'].startswith(broken_versions): return __virtualname__ return False #: ... #: your modified salt module/state #: ...
the __virtual__ function returns the name of the module/state if environment is determined to be suitable. If not, it returns `False` .Since:
- we renamed the module so it does not replace the builtin one
- user modules are earlier on the PYTHONPATH than builtin modules
If this module returns `False`, then it will fall back on the builtin module.