tox is a tool to automatically manage virtual environments, usually for tests and builds. It is used to make sure that those run in well-defined environments and is smart about caching them to reduce churn. True to its roots as a test-running tool, tox is configured in test environments. tox itself is a PyPI package usually installed in a virtual environment. Because tox creates ad hoc temporary...
Wednesday, October 26, 2022
Friday, October 21, 2022
Execution and utility modules
For historical reasons, execution modules go in the file roots _modules subdirectory. Similar to execution modules, they are also synchronized when state.highstate is applied and when explicitly synchronized via saltutil. sync_all.As an example, let’s write an execution module to delete several files to simplify the state module.def multiremove(files):for fname in files:__salt__['file.remove'](fname)Note...
Monday, October 17, 2022
Salt Extensions
Since Salt is written in Python, it is fully extensible in Python. The easiest way to extend Salt for new things is to put files in the file_roots directory on the Salt master. Unfortunately, there is no package manager for Salt extensions yet. Those files automatically get synchronized to the minions, either when running state.apply or explicitly running saltutil.sync_state. The latter is useful...
Wednesday, October 12, 2022
py renderer
Let’s indicate that a file should be parsed with the py renderer with #!py at the top.In that case, the file is interpreted as a Python file. Salt looks for a run function, runs it, and treats the return value as the state.When running, __grains__ and __pillar__ contain the grain and pillar data.As an example, you can implement the same logic with a py renderer.#!pydef run():if __grains__['os'] ==...