Skip to main content

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

  1. Install the plugin via salt-pip:

    salt \* pip.install salt-ext-yte
  2. Enable the renderer in /etc/salt/master and/or /etc/salt/minion:

    renderer:
       - yaml_jinja
       - yte
       - yaml
  3. Restart 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:

  1. `__variables__` A mapping of names to Python expressions (prefixed with ?). These expressions are evaluated once, and their results are bound as local variables.

  2. `__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

  1. Install dev dependencies:

    pip install -r requirements/tests.txt
  2. Test:

    pytest
  3. Lint:

    pip install pre-commit
    pre-commit run -av

Contributing

  1. Fork and branch from master.

  2. Add tests for any new syntax.

  3. Open a PR; reference relevant issue(s); follow SaltStack plugin guidelines.

Metadata

Release files for saltext.yte 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for saltext.yte 1.0.1
File Interpreter ABI Platform
saltext_yte-1.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / saltext_yte-1.0.1-py2.py3-none-any.whl

Download URL saltext_yte-1.0.1-py2.py3-none-any.whl
Size 6.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8577a60e3cf0f148b804f411e56c9d95bfc48f904965430586b69e6d6c53cc66
BLAKE2b-256 checksum
How to use checksums
9835b9c92b23c0b2a9fa09366ab8f089684a09c1299495622d87237aaa0424a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page