Salt Extension for interacting with Yte
Project description
A Salt “renderer” plugin implementing the YTE (YAML-Template-Engine) renderer for SaltStack. Combines plain YAML with embedded template logic (variables, conditionals, loops, custom definitions) without leaving YAML.
Overview
The YTE renderer lets you write Salt states and Pillar data in a single YAML-first syntax, with a small set of directives (__variables__, __definitions__) for setup and Python snippets. It folds into the normal Salt render pipeline and works alongside Jinja/YAML.
Features
YTE renderer plugin for SaltStack (loadable via renderer: yte in your Salt config)
Embedded variables: define defaults, derive from grains/pillar, use Python expressions
Custom definitions: write Python helper functions or blocks and have them execute during render
Standard Salt context: access salt, grains, pillar, opts, __proxy__, saltenv, sls
Fall-through: if no YTE directives are present, it behaves like plain YAML
Requirements
Salt ≥ 3006
Python 3.10+
Installation
Install the plugin via salt-pip:
salt \* pip.install salt-ext-yteEnable the renderer in /etc/salt/master and/or /etc/salt/minion:
renderer: - yaml_jinja - yte - yamlRestart the Salt daemons:
systemctl restart salt-master systemctl restart salt-minion
YTE Constructs
Within any .sls or Pillar file rendered by YTE, you can use two special top-level keys:
`__variables__` A mapping of names to Python expressions (prefixed with ?). These expressions are evaluated once, and their results are bound as local variables.
`__definitions__` A list of Python code blocks. Each block can define helper functions or mutate the variable namespace.
Example vars.sls
#!yte
__variables__:
ray: ?pillar.get("ray", {})
head: ?ray.get("head", grains["master"])
port: ?ray.get("port", 6379)
python: ?grains["pythonexecutable"]
win: ?(grains["os"] == "Windows")
path: ?("C:\\ray_venv" if win else "/opt/ray_venv")
address: ?ray.get("head_address", "")
__definitions__:
- |
def reachable():
salt["mine.update"]()
for ip in salt["mine.get"](head, "network.fqdns"):
if salt["network.ping"](ip, return_boolean=True, timeout=3):
return f"{ip}:{port}"
return "auto"
if not address:
address = reachable()
State Usage Examples
Installing ray wiht relenv:
#!jinja|yte
{% include 'vars.sls' %}
relenv:
pip.installed:
- bin_env: ?python
- upgrade: True
relenv_fetch:
cmd.run:
- name: ?f'"{python}" -m relenv fetch'
- require:
- pip: relenv
ray:
pip.installed:
- pkgs:
- ?if is_head:
"ray[default]"
?else:
ray
- bin_env: ?python
Development
Install dev dependencies:
pip install -r requirements/tests.txtTest:
pytestLint:
pip install pre-commit pre-commit run -av
Contributing
Fork and branch from master.
Add tests for any new syntax.
Open a PR; reference relevant issue(s); follow SaltStack plugin guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saltext_yte-1.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: saltext_yte-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8577a60e3cf0f148b804f411e56c9d95bfc48f904965430586b69e6d6c53cc66
|
|
| MD5 |
b5bffaff721db7975ebe9b64aced9569
|
|
| BLAKE2b-256 |
9835b9c92b23c0b2a9fa09366ab8f089684a09c1299495622d87237aaa0424a4
|