Search code examples
yamlsalt-projectjinja2

Salt Jinja Syntax error: no filter named 'yaml_encode'


When running salt '*' state.highstate, my SLS files fail to render with the following message:

    Data failed to compile:
----------
    Rendering SLS 'base:files' failed: Jinja syntax error: no filter named 'yaml_encode'; line 6

---
{% for folder, options in salt['pillar.get']('dirs', {}).items() %}
{{ folder }}:
{%- load_yaml as foo %}
  file.directory:
    {% for key, val in options.items() %}
    - {{ key }}: {{ val|yaml_encode }}    <======================
    {% endfor %}
    - order: 1
{%- endload %}
{% endfor %}
---

The docs show this filter just being used wherever you want to escape YAML so I don't know why the filter is not defined.

All minions and the master are running Ubuntu Server 14.04, and Salt 2014.7.1 from the Launchpad PPA


Solution

  • Although the filter is documented, it is misleading as the docs are generated from the current develop branch, not the latest stable branch.

    The docs for older versions are available from readthedocs.org.

    The pull request that introduced this feature did not yet get "merged back" into 2014.7.