Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Jinja2 3.0 support breaking changes #60188

Closed
Oloremo opened this issue May 14, 2021 · 15 comments · Fixed by #60811
Closed

[BUG] Jinja2 3.0 support breaking changes #60188

Oloremo opened this issue May 14, 2021 · 15 comments · Fixed by #60811
Assignees
Labels
Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases. severity-high 2nd top severity, seen by most users, causes major problems Silicon v3004.0 Release code name

Comments

@Oloremo
Copy link
Contributor

Oloremo commented May 14, 2021

Jinja2 3.0 was released a few days ago and seems like Salt can't work with it.

We have issues like this:

    Data failed to compile:'
----------'
    Rendering SLS ''base:formula.logstash.common/install'' failed: Jinja variable ''pillar'' is undefined'
/opt/behavox/salt/cache/minion/files/base/formula/kibana/vars.yaml(2):'
---'
---'
{% set third_party_packages_path = pillar.get(''third_party_packages_path'') %}    <======================'
[...]'
@Oloremo Oloremo added Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels May 14, 2021
@sagetherage sagetherage added this to the Approved milestone May 18, 2021
@sagetherage sagetherage self-assigned this May 18, 2021
@myii
Copy link
Contributor

myii commented May 18, 2021

As mentioned in Slack:

I'm wondering if this should actually be considered to be a bug rather than a feature request. We've started seeing failures across various formulas and I did a test run to determine that 32 of around 100 formulas are now failing: https://saltstack-formulas.zulipchat.com/#narrow/stream/239693-CI/topic/myii-ci.2F2021-W20d/search/fail.

Here's an example of a PR that fixes the issue: saltstack-formulas/postgres-formula#311. I'm not so sure this will work everywhere, though.

Should we patch our 32 formulas or should we wait for a resolution in the main Salt repo?

@baby-gnu
Copy link

I agree this is a bug.

The salt special variables are not passed in successive import.

I made a little test where direct-import is working but not indirect-import:

  • /srv/salt/foo/init.sls
# -*- mode: salt; coding: utf-8 -*-
# vim: ft=sls

include:
  - .direct-import
  - .indirect-import
  • /srv/salt/foo/direct-import.sls
# -*- mode: salt; coding: utf-8 -*-
# vim: ft=sls

{%- from "foo/libsaltcli.jinja" import cli %}

test-direct-import-of-cli:
  test.nop:
    - name: {{ cli }}
  • /srv/salt/foo/indirect-import.sls
# -*- mode: salt; coding: utf-8 -*-
# vim: ft=sls

{%- from "foo/test.jinja" import test_cli %}

test-indirect-import-of-cli:
  test.nop:
    - name: {{ test_cli }}
  • /srv/salt/foo/libsaltcli.jinja
# -*- coding: utf-8 -*-
# vim: ft=jinja

{#- Get the relevant values from the `opts` dict #}
{%- set opts_cli = opts.get('__cli', '') %}
{%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}

{#- Determine the type of salt command being run #}
{%- if opts_cli == 'salt-minion' %}
{%-   set cli = 'minion' %}
{%- elif opts_cli == 'salt-call' %}
{%-   set cli = 'ssh' if opts_masteropts_cli in ('salt-ssh', 'salt-master') else 'local' %}
{%- else %}
{%-   set cli = 'unknown' %}
{%- endif %}
{%- do salt['log.debug']('[libsaltcli] the salt command type has been identified to be: ' ~ cli) %}
  • /srv/salt/foo/test.jinja
# -*- coding: utf-8 -*-
# vim: ft=jinja

{%- from "foo/libsaltcli.jinja" import cli %}

{%- set test_cli = cli %}
DEBUG log
root@buster:~/foo-template# ./bin/kitchen converge default-debian-10-master-py3
-----> Starting Test Kitchen (v2.7.2)
-----> Creating <default-debian-10-master-py3>...
       Sending build context to Docker daemon  1.527MB
       Step 1/15 : FROM saltimages/salt-master-py3:debian-10
        ---> d7387439734b
       Step 2/15 : RUN [ ! -f "/sbin/initctl" ] || dpkg-divert --local --rename --add /sbin/initctl                 && ln -sf /bin/true /sbin/initctl
        ---> Using cache
        ---> c4a05d347404
       Step 3/15 : ENV DEBIAN_FRONTEND noninteractive
        ---> Using cache
        ---> 334170a53a0b
       Step 4/15 : ENV container docker
        ---> Using cache
        ---> 62cf5721ebcb
       Step 5/15 : RUN if ! getent passwd kitchen; then                   useradd -d /home/kitchen -m -s /bin/bash -p '*' kitchen;                 fi
        ---> Using cache
        ---> 50fabb644481
       Step 6/15 : RUN echo "kitchen ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/kitchen
        ---> Using cache
        ---> f431fed3317b
       Step 7/15 : RUN echo "Defaults !requiretty" >> /etc/sudoers.d/kitchen
        ---> Using cache
        ---> eab969a55238
       Step 8/15 : RUN mkdir -p /home/kitchen/.ssh
        ---> Using cache
        ---> c37241bc8100
       Step 9/15 : RUN chown -R kitchen /home/kitchen/.ssh
        ---> Using cache
        ---> 481d3f040742
       Step 10/15 : RUN chmod 0700 /home/kitchen/.ssh
        ---> Using cache
        ---> b43a294604bf
       Step 11/15 : RUN touch /home/kitchen/.ssh/authorized_keys
        ---> Using cache
        ---> 92b0e899f03a
       Step 12/15 : RUN chown kitchen /home/kitchen/.ssh/authorized_keys
        ---> Using cache
        ---> 47e6bc8e70f5
       Step 13/15 : RUN chmod 0600 /home/kitchen/.ssh/authorized_keys
        ---> Using cache
        ---> 44a65bbab94f
       Step 14/15 : RUN mkdir -p /run/sshd
        ---> Using cache
        ---> 54055f04ed28
       Step 15/15 : RUN echo ssh-rsa\ AAAAB3NzaC1yc2EAAAADAQABAAABAQDtXRBQobr6N22\+mW\+ve6SDKyUJHIyrMYHYw0TxKw7C69E/JxZQuBHklfNHXAEVkvit0f7iptN3cZIOy7rBXd4iWtX0Je6TdTMrPfkxO/cBdaRrcsqdKQPTUSMLmozncNk0VXpI7xL8cfSfqFiggqNgQbuCh/RC/ziXDQPwqZzD9WQD0sF3r6TC\+jAEoP6YWnUqREiTKOSc5UBsPgPKza6vNp\+El8G8Z78pqG6gJ7NIDe4lbXxrSCF2b5m9Cm6QJyy6OFrSCNW2D4hu2/BvHWGT81JBMH3PgXefPbLYIwvK/kREu4jBROFEHMSBirQm1JKpfEubB/mFPXxNbvgMjM1B\ kitchen_docker_key >> /home/kitchen/.ssh/authorized_keys
        ---> Using cache
        ---> 02deffd10007
       Successfully built 02deffd10007
       2c23c82f968ca76ecedd9c1592888a233abbc0989643a5aac6210254895ce0c0
       0.0.0.0:36392
       Waiting for SSH service on localhost:36392, retrying in 3 seconds
       [SSH] Established
       Finished creating <default-debian-10-master-py3> (0m3.94s).
-----> Converging <default-debian-10-master-py3>...
       Preparing files for transfer
       Preparing salt-minion
       Preparing pillars into /srv/pillar
       Preparing formula: foo from /root/foo-template
       Preparing state_top
       Preparing scripts into /etc/salt/scripts
       You asked for latest and you have 3003+0na.82c373d installed, sweet!
       Transferring files to <default-debian-10-master-py3>
       Install External Dependencies
       Content of /tmp/kitchen//srv/salt :
       total 16
       drwxr-xr-x 3 kitchen kitchen 4096 May 18 09:58 .
       drwxr-xr-x 3 kitchen kitchen 4096 May 18 09:58 ..
       drwxr-xr-x 2 kitchen kitchen 4096 May 18 09:58 foo
       -rw-r--r-- 1 kitchen kitchen   25 May 18 09:58 top.sls
       [DEBUG   ] Reading configuration from /tmp/kitchen/etc/salt/minion
       [DEBUG   ] Guessing ID. The id can be explicitly set in /etc/salt/minion
       [DEBUG   ] Found minion id from generate_minion_id(): 2c23c82f968c
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Override  __grains__: <module 'salt.loaded.int.log_handlers.sentry_mod' from '/usr/local/lib/python3.7/dist-packages/salt/log/handlers/sentry_mod.py'>
       [DEBUG   ] Configuration file path: /tmp/kitchen/etc/salt/minion
       [WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
       [DEBUG   ] Grains refresh requested. Refreshing grains.
       [DEBUG   ] Reading configuration from /tmp/kitchen/etc/salt/minion
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Override  __utils__: <module 'salt.loaded.int.grains.zfs' from '/usr/local/lib/python3.7/dist-packages/salt/grains/zfs.py'>
       [DEBUG   ] Elapsed time getting FQDNs: 0.11402416229248047 seconds
       [DEBUG   ] LazyLoaded zfs.is_supported
       [DEBUG   ] Determining pillar cache
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded jinja.render
       [DEBUG   ] LazyLoaded yaml.render
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded jinja.render
       [DEBUG   ] LazyLoaded yaml.render
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded state.highstate
       [DEBUG   ] LazyLoaded direct_call.execute
       [DEBUG   ] Override  __grains__: <module 'salt.loaded.int.module.grains' from '/usr/local/lib/python3.7/dist-packages/salt/modules/grains.py'>
       [DEBUG   ] LazyLoaded grains.get
       [DEBUG   ] LazyLoaded saltutil.is_running
       [DEBUG   ] LazyLoaded config.get
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [DEBUG   ] Updating roots fileserver cache
       [DEBUG   ] Gathering pillar data for state run
       [DEBUG   ] Determining pillar cache
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded jinja.render
       [DEBUG   ] LazyLoaded yaml.render
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Finished gathering pillar data for state run
       [INFO    ] Loading fresh modules for state activity
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded jinja.render
       [DEBUG   ] LazyLoaded yaml.render
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] In saltenv 'base', looking at rel_path 'top.sls' to resolve 'salt://top.sls'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/top.sls' to resolve 'salt://top.sls'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://top.sls'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'top.sls'
       [DEBUG   ] compile template: /tmp/kitchen/var/cache/salt/minion/files/base/top.sls
       [DEBUG   ] Jinja search path: ['/tmp/kitchen/var/cache/salt/minion/files/base']
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/top.sls' using 'jinja' renderer: 0.021555423736572266
       [DEBUG   ] Rendered data from file: /tmp/kitchen/var/cache/salt/minion/files/base/top.sls:
       ---
       base:
         "*":
         - foo
       
       [DEBUG   ] Results of YAML rendering: 
       OrderedDict([('base', OrderedDict([('*', ['foo'])]))])
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/top.sls' using 'yaml' renderer: 0.00038504600524902344
       [DEBUG   ] LazyLoaded confirm_top.confirm_top
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded compound_match.match
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] compound_match: 2c23c82f968c ? *
       [DEBUG   ] LazyLoaded glob_match.match
       [DEBUG   ] compound_match 2c23c82f968c ? "*" => "True"
       [DEBUG   ] LazyLoaded saltutil.sync_all
       [DEBUG   ] Syncing all
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/clouds'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing clouds for environment 'base'
       [INFO    ] Loading cache from salt://_clouds, for base
       [INFO    ] Caching directory '_clouds/' for environment 'base'
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_clouds'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/beacons'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing beacons for environment 'base'
       [INFO    ] Loading cache from salt://_beacons, for base
       [INFO    ] Caching directory '_beacons/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=0 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_beacons'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/modules'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing modules for environment 'base'
       [INFO    ] Loading cache from salt://_modules, for base
       [INFO    ] Caching directory '_modules/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=0 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_modules'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/states'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing states for environment 'base'
       [INFO    ] Loading cache from salt://_states, for base
       [INFO    ] Caching directory '_states/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=0 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_states'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/sdb'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing sdb for environment 'base'
       [INFO    ] Loading cache from salt://_sdb, for base
       [INFO    ] Caching directory '_sdb/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=0 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_sdb'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/grains'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing grains for environment 'base'
       [INFO    ] Loading cache from salt://_grains, for base
       [INFO    ] Caching directory '_grains/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_grains'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/renderers'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing renderers for environment 'base'
       [INFO    ] Loading cache from salt://_renderers, for base
       [INFO    ] Caching directory '_renderers/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_renderers'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/returners'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing returners for environment 'base'
       [INFO    ] Loading cache from salt://_returners, for base
       [INFO    ] Caching directory '_returners/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_returners'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/output'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing output for environment 'base'
       [INFO    ] Loading cache from salt://_output, for base
       [INFO    ] Caching directory '_output/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_output'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/utils'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing utils for environment 'base'
       [INFO    ] Loading cache from salt://_utils, for base
       [INFO    ] Caching directory '_utils/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_utils'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/log_handlers'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing log_handlers for environment 'base'
       [INFO    ] Loading cache from salt://_log_handlers, for base
       [INFO    ] Caching directory '_log_handlers/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_log_handlers'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/executors'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing executors for environment 'base'
       [INFO    ] Loading cache from salt://_executors, for base
       [INFO    ] Caching directory '_executors/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_executors'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/proxy'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing proxy for environment 'base'
       [INFO    ] Loading cache from salt://_proxy, for base
       [INFO    ] Caching directory '_proxy/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_proxy'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/engines'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing engines for environment 'base'
       [INFO    ] Loading cache from salt://_engines, for base
       [INFO    ] Caching directory '_engines/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_engines'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/thorium'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing thorium for environment 'base'
       [INFO    ] Loading cache from salt://_thorium, for base
       [INFO    ] Caching directory '_thorium/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_thorium'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/serializers'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing serializers for environment 'base'
       [INFO    ] Loading cache from salt://_serializers, for base
       [INFO    ] Caching directory '_serializers/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_serializers'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/matchers'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing matchers for environment 'base'
       [INFO    ] Loading cache from salt://_matchers, for base
       [INFO    ] Caching directory '_matchers/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_matchers'
       [INFO    ] Creating module dir '/tmp/kitchen/var/cache/salt/minion/extmods/pillar'
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded roots.envs
       [DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
       [INFO    ] Syncing pillar for environment 'base'
       [INFO    ] Loading cache from salt://_pillar, for base
       [INFO    ] Caching directory '_pillar/' for environment 'base'
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Local cache dir: '/tmp/kitchen/var/cache/salt/minion/files/base/_pillar'
       [DEBUG   ] Refreshing modules...
       [INFO    ] Loading fresh modules for state activity
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded jinja.render
       [DEBUG   ] LazyLoaded yaml.render
       [DEBUG   ] Returning file list from cache: age=1 cache_time=20 /tmp/kitchen/var/cache/salt/minion/file_lists/roots/base.p
       [DEBUG   ] Could not find file 'salt://foo.sls' in saltenv 'base'
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/init.sls' to resolve 'salt://foo/init.sls'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls' to resolve 'salt://foo/init.sls'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/init.sls'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/init.sls'
       [DEBUG   ] compile template: /tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls
       [DEBUG   ] Jinja search path: ['/tmp/kitchen/var/cache/salt/minion/files/base']
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls' using 'jinja' renderer: 0.0010530948638916016
       [DEBUG   ] Rendered data from file: /tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls:
       # -*- mode: salt; coding: utf-8 -*-
       # vim: ft=sls
       
       include:
         - .direct-import
         - .indirect-import
       
       [DEBUG   ] Results of YAML rendering: 
       OrderedDict([('include', ['.direct-import', '.indirect-import'])])
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls' using 'yaml' renderer: 0.00033926963806152344
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/direct-import.sls' to resolve 'salt://foo/direct-import.sls'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/direct-import.sls' to resolve 'salt://foo/direct-import.sls'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/direct-import.sls'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/direct-import.sls'
       [DEBUG   ] compile template: /tmp/kitchen/var/cache/salt/minion/files/base/foo/direct-import.sls
       [DEBUG   ] Jinja search path: ['/tmp/kitchen/var/cache/salt/minion/files/base']
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/libsaltcli.jinja' to resolve 'salt://foo/libsaltcli.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja' to resolve 'salt://foo/libsaltcli.jinja'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/libsaltcli.jinja'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/libsaltcli.jinja'
       [DEBUG   ] LazyLoaded log.debug
       [DEBUG   ] [libsaltcli] the salt command type has been identified to be: local
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/foo/direct-import.sls' using 'jinja' renderer: 0.012192964553833008
       [DEBUG   ] Rendered data from file: /tmp/kitchen/var/cache/salt/minion/files/base/foo/direct-import.sls:
       # -*- mode: salt; coding: utf-8 -*-
       # vim: ft=sls
       
       test-direct-import-of-cli:
         test.nop:
           - name: local
       
       [DEBUG   ] Results of YAML rendering: 
       OrderedDict([('test-direct-import-of-cli', OrderedDict([('test.nop', [OrderedDict([('name', 'local')])])]))])
       [PROFILE ] Time (in seconds) to render '/tmp/kitchen/var/cache/salt/minion/files/base/foo/direct-import.sls' using 'yaml' renderer: 0.00030684471130371094
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/indirect-import.sls' to resolve 'salt://foo/indirect-import.sls'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/indirect-import.sls' to resolve 'salt://foo/indirect-import.sls'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/indirect-import.sls'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/indirect-import.sls'
       [DEBUG   ] compile template: /tmp/kitchen/var/cache/salt/minion/files/base/foo/indirect-import.sls
       [DEBUG   ] Jinja search path: ['/tmp/kitchen/var/cache/salt/minion/files/base']
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/test.jinja' to resolve 'salt://foo/test.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/test.jinja' to resolve 'salt://foo/test.jinja'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/test.jinja'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/test.jinja'
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/libsaltcli.jinja' to resolve 'salt://foo/libsaltcli.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja' to resolve 'salt://foo/libsaltcli.jinja'
       [ERROR   ] Rendering exception occurred
       Traceback (most recent call last):
         File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 497, in render_jinja_tmpl
           output = template.render(**decoded_context)
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1289, in render
           self.environment.handle_exception()
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 924, in handle_exception
           raise rewrite_traceback_stack(source=source)
         File "<template>", line 4, in top-level template code
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1394, in make_module
           return TemplateModule(self, ctx)
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1524, in __init__
           body_stream = list(template.root_render_func(context))  # type: ignore
         File "/tmp/kitchen/var/cache/salt/minion/files/base/foo/test.jinja", line 4, in top-level template code
           {%- from "foo/libsaltcli.jinja" import cli %}
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1394, in make_module
           return TemplateModule(self, ctx)
         File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1524, in __init__
           body_stream = list(template.root_render_func(context))  # type: ignore
         File "/tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja", line 5, in top-level template code
           {%- set opts_cli = opts.get('__cli', '') %}
         File "/usr/local/lib/python3.7/dist-packages/jinja2/sandbox.py", line 326, in getattr
           value = getattr(obj, attribute)
       jinja2.exceptions.UndefinedError: 'opts' is undefined
       
       During handling of the above exception, another exception occurred:
       
       Traceback (most recent call last):
         File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 261, in render_tmpl
           output = render_str(tmplstr, context, tmplpath)
         File "/usr/local/lib/python3.7/dist-packages/salt/utils/templates.py", line 504, in render_jinja_tmpl
           raise SaltRenderError("Jinja variable {}{}".format(exc, out), buf=tmplstr)
       salt.exceptions.SaltRenderError: Jinja variable 'opts' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja(5):
       ---
       # -*- coding: utf-8 -*-
       # vim: ft=jinja
       
       {#- Get the relevant values from the `opts` dict #}
       {%- set opts_cli = opts.get('__cli', '') %}    <======================
       {%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}
       
       {#- Determine the type of salt command being run #}
       {%- if opts_cli == 'salt-minion' %}
       {%-   set cli = 'minion' %}
       [...]
       ---
       [CRITICAL] Rendering SLS 'base:foo.indirect-import' failed: Jinja variable 'opts' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja(5):
       ---
       # -*- coding: utf-8 -*-
       # vim: ft=jinja
       
       {#- Get the relevant values from the `opts` dict #}
       {%- set opts_cli = opts.get('__cli', '') %}    <======================
       {%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}
       
       {#- Determine the type of salt command being run #}
       {%- if opts_cli == 'salt-minion' %}
       {%-   set cli = 'minion' %}
       [...]
       ---
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded highstate.output
       local:
           Data failed to compile:
       ----------
           Rendering SLS 'base:foo.indirect-import' failed: Jinja variable 'opts' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/libsaltcli.jinja(5):
       ---
       # -*- coding: utf-8 -*-
       # vim: ft=jinja
       
       {#- Get the relevant values from the `opts` dict #}
       {%- set opts_cli = opts.get('__cli', '') %}    <======================
       {%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}
       
       {#- Determine the type of salt command being run #}
       {%- if opts_cli == 'salt-minion' %}
       {%-   set cli = 'minion' %}
       [...]
       ---
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-debian-10-master-py3>.  Please see .kitchen/logs/default-debian-10-master-py3.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

@baby-gnu
Copy link

The salt special variables are not passed in successive import.

It works if I modify /srv/salt/foo/test.jinja like this:

--- foo/test.jinja.orig	2021-05-18 12:07:27.592339605 +0200
+++ foo/test.jinja	2021-05-18 12:06:25.054300769 +0200
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 # vim: ft=jinja
 
-{%- from "foo/libsaltcli.jinja" import cli %}
+{%- from "foo/libsaltcli.jinja" import cli with context %}
 
 {%- set test_cli = cli %}

@baby-gnu
Copy link

This is a major change since we may want to have the salt special variables even without context like in saltstack-formulas/template-formula#230 (comment)

@myii
Copy link
Contributor

myii commented May 19, 2021

For the Formulas' team, we're rebuilding our CI images to force the downgrade of Jinja2 from 3.0.x to 2.11.3. That's got our CI working again. Obviously, this is only a workaround until the result of this feature request (bug report?) is clear.

@ggiesen
Copy link
Contributor

ggiesen commented May 20, 2021

If/when this gets addressed, could we get #35398 addressed at the same time?

@sagetherage sagetherage added Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases. severity-high 2nd top severity, seen by most users, causes major problems Silicon v3004.0 Release code name and removed Feature new functionality including changes to functionality and code refactors, etc. labels Jun 8, 2021
@sagetherage sagetherage modified the milestones: Approved, Silicon Jun 8, 2021
@sagetherage sagetherage removed their assignment Jun 8, 2021
@sagetherage sagetherage changed the title [FEATURE REQUEST] Jinja2 3.0 support [BUG] Jinja2 3.0 support breaking changes Jun 8, 2021
@myii
Copy link
Contributor

myii commented Jul 14, 2021

Now affecting openSUSE Tumbleweed stable builds with the salt-bootstrap. That's alongside Arch Linux stable builds and most/all of the git builds.

saltstack-formulas-github pushed a commit to netmanagers/salt-image-builder that referenced this issue Jul 22, 2021
Note, `Jinja2` wasn't downgraded, as per the upstream issue
(saltstack/salt#60188) -- appears that this
will need to be done for the `master` pre-salted boxes.
@myii
Copy link
Contributor

myii commented Jul 22, 2021

Now affecting openSUSE Tumbleweed stable builds with the salt-bootstrap. That's alongside Arch LInux stable builds and most/all of the git builds.

And now also affects our newly built pre-salted master FreeBSD Vagrant boxes:


Update: I've uploaded version 2021.07.22 for all three above that now includes the Jinja2 downgrade workaround (which is actually working with our formulas again). So if anyone is checking out these boxes, the 2021.07.21 version is the one with Jinja2 3.0.1.

@aboe76
Copy link
Contributor

aboe76 commented Jul 22, 2021

@myii for openSUSE Tumbleweed users, they can download the following rpm to downgrade:
http://download.opensuse.org/history/20210710/tumbleweed/repo/oss/x86_64/python38-Jinja2-2.11.3-1.4.x86_64.rpm

And then add lock on it, so it won't get accidentally upgraded again.

sudo zypper addlock python38-jinja2 -t package

@myii
Copy link
Contributor

myii commented Jul 22, 2021

@myii for openSUSE Tumbleweed users, they can download the following rpm to downgrade:
http://download.opensuse.org/history/20210710/tumbleweed/repo/oss/x86_64/python38-Jinja2-2.11.3-1.4.x86_64.rpm

And then add lock on it, so it won't get accidentally upgraded again.

sudo zypper addlock python38-jinja2 -t package

Thanks, @aboe76 -- we've already got that in the Salt image builder:

However, the problem is that the history is only around for ~25 days.

@baby-gnu
Copy link

I tried to look at the code to see if I can see something but it's a little too complex for my skills, I'm lost between salt.template.compile_template(), salt.renderers.jinja.render and salt.utils.templates.JINJA().

I can see the grains, pillar and opts variables passed and keyword arguments merged as a context variable and used in the rendering call which is then passed as template globals.

I'll try to find some time to setup a Jinja3 salt environment and see how I could follow the evolution of context content.

Regards.

@baby-gnu
Copy link

A minimal example to test

  • foo/init.sls

    {%- from "foo/map.jinja" import mapdata %}
    
    test-imported-values:
      test.nop:
        - name: {{ mapdata }}
  • foo/map.jinja

    {%- from "foo/sub-import.jinja" import subdata %}
    {%- set mapdata = subdata %}
  • foo/sub-import.jinja

    {%- set subdata = salt["pillar.get"]("foo") %}

I added some logging added to salt.utils.templates.render_jinja_tmpl()

some logs
       [ERROR   ] DEBUG RENGER JINJA TMPL PATH /tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls
       [ERROR   ] DEBUG RENGER JINJA TMPL STR # -*- coding: utf-8 -*-
       # vim: ft=sls
       
       {%- from "foo/map.jinja" import mapdata %}
       
       test-imported-values:
         test.nop:
           - name: {{ mapdata }}
       
       [DEBUG   ] Jinja search path: ['/tmp/kitchen/var/cache/salt/minion/files/base']
       [DEBUG   ] DECODED CONTEXT {'salt': <salt.utils.templates.AliasedLoader object at 0x7f678662a3d0>, 'grains': {'cwd': '/home/kitchen', 'dns': {'nameservers': ['192.168.232.2'], 'ip4_nameservers': ['192.168.232.2'], 'ip6_nameservers': [], 'sortlist': [], 'domain': '', 'search': [], 'options': []}, 'fqdns': ['4b2f672e8e3b'], 'machine_id': '112c9c9cf387456189816c4a727e4cc3', 'master': 'salt', 'server_id': 1031764925, 'localhost': '4b2f672e8e3b', 'fqdn': '4b2f672e8e3b', 'host': '4b2f672e8e3b', 'domain': '', 'hwaddr_interfaces': {'eth0': '02:42:ac:11:00:03'}, 'id': '4b2f672e8e3b', 'ip4_interfaces': {'eth0': ['172.17.0.3'], 'lo': ['127.0.0.1']}, 'ip6_interfaces': {'eth0': [], 'lo': []}, 'ipv4': ['127.0.0.1', '172.17.0.3'], 'ipv6': [], 'fqdn_ip4': ['172.17.0.3'], 'fqdn_ip6': [], 'ip_interfaces': {'eth0': ['172.17.0.3'], 'lo': ['127.0.0.1']}, 'kernelparams': [('BOOT_IMAGE', '/vmlinuz-5.10.0-8-amd64'), ('root', '/dev/mapper/bullseye--vg-root'), ('ro', None), ('quiet', None)], 'locale_info': {'defaultlanguage': 'fr_FR', 'defaultencoding': 'UTF-8', 'detectedencoding': 'utf-8', 'timezone': 'unknown'}, 'num_gpus': 0, 'gpus': [], 'kernel': 'Linux', 'nodename': '4b2f672e8e3b', 'kernelrelease': '5.10.0-8-amd64', 'kernelversion': '#1 SMP Debian 5.10.46-4 (2021-08-03)', 'cpuarch': 'x86_64', 'systemd': {'version': '248', 'features': '+PAM +AUDIT +SELINUX +APPARMOR -IMA -SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN -IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified'}, 'init': 'systemd', 'lsb_distrib_id': 'openSUSE Tumbleweed', 'lsb_distrib_release': '20210824', 'lsb_distrib_codename': 'openSUSE Tumbleweed', 'os': 'SUSE', 'osfullname': 'openSUSE Tumbleweed', 'osrelease': '20210824', 'oscodename': 'openSUSE Tumbleweed', 'num_cpus': 2, 'cpu_model': 'QEMU Virtual CPU version 2.5+', 'cpu_flags': ['fpu', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 'cx8', 'apic', 'sep', 'mtrr', 'pge', 'mca', 'cmov', 'pse36', 'clflush', 'mmx', 'fxsr', 'sse', 'sse2', 'syscall', 'nx', 'lm', 'rep_good', 'nopl', 'xtopology', 'cpuid', 'tsc_known_freq', 'pni', 'cx16', 'x2apic', 'hypervisor', 'lahf_lm', 'cpuid_fault', 'pti'], 'os_family': 'Suse', 'osarch': 'x86_64', 'mem_total': 976, 'swap_total': 1275, 'biosversion': '1.12.0-1', 'productname': 'Standard PC (Q35 + ICH9, 2009)', 'manufacturer': 'QEMU', 'biosreleasedate': '04/01/2014', 'uuid': '3e59a4f2-2890-4866-85a3-0946406c2336', 'serialnumber': '', 'virtual': 'kvm', 'ps': 'ps -efHww', 'osrelease_info': (20210824,), 'osmajorrelease': 20210824, 'osfinger': 'openSUSE Tumbleweed-20210824', 'path': '/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin', 'systempath': ['/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/local/bin', '/usr/local/sbin'], 'pythonexecutable': '/usr/bin/python3.8', 'pythonpath': ['/usr/bin', '/usr/lib/python38.zip', '/usr/lib64/python3.8', '/usr/lib64/python3.8/lib-dynload', '/usr/lib64/python3.8/site-packages', '/usr/lib64/python3.8/_import_failed', '/usr/lib/python3.8/site-packages', '/usr/local/lib/python3.8/site-packages'], 'pythonversion': [3, 8, 11, 'final', 0], 'saltpath': '/usr/lib/python3.8/site-packages/salt', 'saltversion': '3004+0na.38906ff', 'saltversioninfo': [3004], 'zmqversion': '4.3.3', 'disks': ['sr0', 'sda'], 'ssds': [], 'shell': '/bin/bash', 'transactional': False, 'efi': False, 'efi-secure-boot': False, 'username': 'root', 'groupname': 'root', 'pid': 3861, 'gid': 0, 'uid': 0, 'zfs_support': False, 'zfs_feature_flags': False}, 'opts': {'interface': '0.0.0.0', 'master': 'salt', 'master_type': 'str', 'master_uri_format': 'default', 'source_interface_name': '', 'source_address': '', 'source_ret_port': 0, 'source_publish_port': 0, 'master_port': 4506, 'master_finger': '', 'master_shuffle': False, 'master_alive_interval': 0, 'master_failback': False, 'master_failback_interval': 0, 'verify_master_pubkey_sign': False, 'sign_pub_messages': False, 'always_verify_signature': False, 'master_sign_key_name': 'master_sign', 'syndic_finger': '', 'user': 'root', 'root_dir': '/tmp/kitchen', 'pki_dir': '/tmp/kitchen/etc/salt/pki/minion', 'id': '4b2f672e8e3b', 'id_function': {}, 'cachedir': '/tmp/kitchen/var/cache/salt/minion', 'append_minionid_config_dirs': [], 'cache_jobs': False, 'grains_blacklist': [], 'grains_cache': False, 'grains_cache_expiration': 300, 'grains_deep_merge': False, 'conf_file': '/tmp/kitchen/etc/salt/minion', 'sock_dir': '/tmp/kitchen/var/run/salt/minion', 'sock_pool_size': 1, 'backup_mode': '', 'renderer': 'jinja|yaml', 'renderer_whitelist': [], 'renderer_blacklist': [], 'random_startup_delay': 0, 'failhard': False, 'autoload_dynamic_modules': True, 'saltenv': None, 'lock_saltenv': False, 'pillarenv': None, 'pillarenv_from_saltenv': False, 'pillar_opts': False, 'pillar_source_merging_strategy': 'smart', 'pillar_merge_lists': False, 'pillar_includes_override_sls': False, 'pillar_cache': False, 'pillar_cache_ttl': 3600, 'pillar_cache_backend': 'disk', 'gpg_cache': False, 'gpg_cache_ttl': 86400, 'gpg_cache_backend': 'disk', 'extension_modules': '/tmp/kitchen/var/cache/salt/minion/extmods', 'state_top': 'salt://top.sls', 'state_top_saltenv': None, 'startup_states': '', 'sls_list': [], 'start_event_grains': [], 'top_file': '', 'thoriumenv': None, 'thorium_top': 'top.sls', 'thorium_interval': 0.5, 'thorium_roots': {'base': ['/srv/thorium']}, 'file_client': 'local', 'local': True, 'use_master_when_local': False, 'file_roots': {'base': ['/tmp/kitchen/srv/salt', '/tmp/kitchen/srv/spm/salt']}, 'top_file_merging_strategy': 'merge', 'env_order': [], 'default_top': 'base', 'fileserver_limit_traversal': False, 'file_recv': False, 'file_recv_max_size': 100, 'file_ignore_regex': [], 'file_ignore_glob': [], 'fileserver_backend': ['roots'], 'fileserver_followsymlinks': True, 'fileserver_ignoresymlinks': False, 'pillar_roots': {'base': ['/tmp/kitchen/srv/pillar', '/tmp/kitchen/srv/spm/pillar']}, 'on_demand_ext_pillar': ['libvirt', 'virtkey'], 'decrypt_pillar': [], 'decrypt_pillar_delimiter': ':', 'decrypt_pillar_default': 'gpg', 'decrypt_pillar_renderers': ['gpg'], 'roots_update_interval': 60, 'azurefs_update_interval': 60, 'gitfs_update_interval': 60, 'git_pillar_update_interval': 60, 'hgfs_update_interval': 60, 'minionfs_update_interval': 60, 's3fs_update_interval': 60, 'svnfs_update_interval': 60, 'git_pillar_base': 'master', 'git_pillar_branch': 'master', 'git_pillar_env': '', 'git_pillar_fallback': '', 'git_pillar_root': '', 'git_pillar_ssl_verify': True, 'git_pillar_global_lock': True, 'git_pillar_user': '', 'git_pillar_password': '', 'git_pillar_insecure_auth': False, 'git_pillar_privkey': '', 'git_pillar_pubkey': '', 'git_pillar_passphrase': '', 'git_pillar_refspecs': ['+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*'], 'git_pillar_includes': True, 'gitfs_remotes': [], 'gitfs_mountpoint': '', 'gitfs_root': '', 'gitfs_base': 'master', 'gitfs_fallback': '', 'gitfs_user': '', 'gitfs_password': '', 'gitfs_insecure_auth': False, 'gitfs_privkey': '', 'gitfs_pubkey': '', 'gitfs_passphrase': '', 'gitfs_saltenv_whitelist': [], 'gitfs_saltenv_blacklist': [], 'gitfs_global_lock': True, 'gitfs_ssl_verify': True, 'gitfs_saltenv': [], 'gitfs_ref_types': ['branch', 'tag', 'sha'], 'gitfs_refspecs': ['+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*'], 'gitfs_disable_saltenv_mapping': False, 'unique_jid': False, 'hash_type': 'sha256', 'optimization_order': [0, 1, 2], 'disable_modules': [], 'disable_returners': [], 'whitelist_modules': [], 'module_dirs': [], 'returner_dirs': [], 'grains_dirs': [], 'states_dirs': [], 'render_dirs': [], 'outputter_dirs': [], 'utils_dirs': ['/var/cache/salt/minion/extmods/utils'], 'publisher_acl': {}, 'publisher_acl_blacklist': {}, 'providers': {}, 'clean_dynamic_modules': True, 'open_mode': False, 'auto_accept': True, 'autosign_timeout': 120, 'multiprocessing': True, 'process_count_max': -1, 'mine_enabled': True, 'mine_return_job': False, 'mine_interval': 60, 'ipc_mode': 'ipc', 'ipc_write_buffer': 0, 'ipv6': None, 'file_buffer_size': 262144, 'tcp_pub_port': 4510, 'tcp_pull_port': 4511, 'tcp_authentication_retries': 5, 'tcp_reconnect_backoff': 1, 'log_file': '/tmp/kitchen/var/log/salt/minion', 'log_level': 'debug', 'log_datefmt': '%H:%M:%S', 'log_datefmt_logfile': '%Y-%m-%d %H:%M:%S', 'log_fmt_console': '[%(levelname)-8s] %(message)s', 'log_fmt_logfile': '%(asctime)s,%(msecs)03d [%(name)-17s:%(lineno)-4d][%(levelname)-8s][%(process)d] %(message)s', 'log_fmt_jid': '[JID: %(jid)s]', 'log_granular_levels': {}, 'log_rotate_max_bytes': 0, 'log_rotate_backup_count': 0, 'max_event_size': 1048576, 'enable_legacy_startup_events': True, 'test': False, 'ext_job_cache': '', 'cython_enable': False, 'enable_fqdns_grains': True, 'enable_gpu_grains': True, 'enable_zip_modules': False, 'state_verbose': True, 'state_output': 'changes', 'state_output_diff': False, 'state_output_profile': True, 'state_auto_order': True, 'state_events': False, 'state_aggregate': False, 'snapper_states': False, 'snapper_states_config': 'root', 'acceptance_wait_time': 10, 'acceptance_wait_time_max': 0, 'rejected_retry': False, 'loop_interval': 1, 'verify_env': True, 'grains': {'cwd': '/home/kitchen', 'dns': {'nameservers': ['192.168.232.2'], 'ip4_nameservers': ['192.168.232.2'], 'ip6_nameservers': [], 'sortlist': [], 'domain': '', 'search': [], 'options': []}, 'fqdns': ['4b2f672e8e3b'], 'machine_id': '112c9c9cf387456189816c4a727e4cc3', 'master': 'salt', 'server_id': 1031764925, 'localhost': '4b2f672e8e3b', 'fqdn': '4b2f672e8e3b', 'host': '4b2f672e8e3b', 'domain': '', 'hwaddr_interfaces': {'eth0': '02:42:ac:11:00:03'}, 'id': '4b2f672e8e3b', 'ip4_interfaces': {'eth0': ['172.17.0.3'], 'lo': ['127.0.0.1']}, 'ip6_interfaces': {'eth0': [], 'lo': []}, 'ipv4': ['127.0.0.1', '172.17.0.3'], 'ipv6': [], 'fqdn_ip4': ['172.17.0.3'], 'fqdn_ip6': [], 'ip_interfaces': {'eth0': ['172.17.0.3'], 'lo': ['127.0.0.1']}, 'kernelparams': [('BOOT_IMAGE', '/vmlinuz-5.10.0-8-amd64'), ('root', '/dev/mapper/bullseye--vg-root'), ('ro', None), ('quiet', None)], 'locale_info': {'defaultlanguage': 'fr_FR', 'defaultencoding': 'UTF-8', 'detectedencoding': 'utf-8', 'timezone': 'unknown'}, 'num_gpus': 0, 'gpus': [], 'kernel': 'Linux', 'nodename': '4b2f672e8e3b', 'kernelrelease': '5.10.0-8-amd64', 'kernelversion': '#1 SMP Debian 5.10.46-4 (2021-08-03)', 'cpuarch': 'x86_64', 'systemd': {'version': '248', 'features': '+PAM +AUDIT +SELINUX +APPARMOR -IMA -SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN -IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified'}, 'init': 'systemd', 'lsb_distrib_id': 'openSUSE Tumbleweed', 'lsb_distrib_release': '20210824', 'lsb_distrib_codename': 'openSUSE Tumbleweed', 'os': 'SUSE', 'osfullname': 'openSUSE Tumbleweed', 'osrelease': '20210824', 'oscodename': 'openSUSE Tumbleweed', 'num_cpus': 2, 'cpu_model': 'QEMU Virtual CPU version 2.5+', 'cpu_flags': ['fpu', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 'cx8', 'apic', 'sep', 'mtrr', 'pge', 'mca', 'cmov', 'pse36', 'clflush', 'mmx', 'fxsr', 'sse', 'sse2', 'syscall', 'nx', 'lm', 'rep_good', 'nopl', 'xtopology', 'cpuid', 'tsc_known_freq', 'pni', 'cx16', 'x2apic', 'hypervisor', 'lahf_lm', 'cpuid_fault', 'pti'], 'os_family': 'Suse', 'osarch': 'x86_64', 'mem_total': 976, 'swap_total': 1275, 'biosversion': '1.12.0-1', 'productname': 'Standard PC (Q35 + ICH9, 2009)', 'manufacturer': 'QEMU', 'biosreleasedate': '04/01/2014', 'uuid': '3e59a4f2-2890-4866-85a3-0946406c2336', 'serialnumber': '', 'virtual': 'kvm', 'ps': 'ps -efHww', 'osrelease_info': (20210824,), 'osmajorrelease': 20210824, 'osfinger': 'openSUSE Tumbleweed-20210824', 'path': '/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin', 'systempath': ['/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/local/bin', '/usr/local/sbin'], 'pythonexecutable': '/usr/bin/python3.8', 'pythonpath': ['/usr/bin', '/usr/lib/python38.zip', '/usr/lib64/python3.8', '/usr/lib64/python3.8/lib-dynload', '/usr/lib64/python3.8/site-packages', '/usr/lib64/python3.8/_import_failed', '/usr/lib/python3.8/site-packages', '/usr/local/lib/python3.8/site-packages'], 'pythonversion': [3, 8, 11, 'final', 0], 'saltpath': '/usr/lib/python3.8/site-packages/salt', 'saltversion': '3004+0na.38906ff', 'saltversioninfo': [3004], 'zmqversion': '4.3.3', 'disks': ['sr0', 'sda'], 'ssds': [], 'shell': '/bin/bash', 'transactional': False, 'efi': False, 'efi-secure-boot': False, 'username': 'root', 'groupname': 'root', 'pid': 3861, 'gid': 0, 'uid': 0, 'zfs_support': False, 'zfs_feature_flags': False}, 'permissive_pki_access': False, 'default_include': 'minion.d/*.conf', 'update_url': False, 'update_restart_services': [], 'retry_dns': 30, 'retry_dns_count': None, 'resolve_dns_fallback': True, 'recon_max': 10000, 'recon_default': 1000, 'recon_randomize': True, 'return_retry_timer': 5, 'return_retry_timer_max': 10, 'return_retry_tries': 3, 'random_reauth_delay': 10, 'winrepo_source_dir': 'salt://win/repo-ng/', 'winrepo_dir': '/srv/salt/win/repo', 'winrepo_dir_ng': '/srv/salt/win/repo-ng', 'winrepo_cachefile': 'winrepo.p', 'winrepo_cache_expire_max': 604800, 'winrepo_cache_expire_min': 1800, 'winrepo_remotes': ['https://github.com/saltstack/salt-winrepo.git'], 'winrepo_remotes_ng': ['https://github.com/saltstack/salt-winrepo-ng.git'], 'winrepo_branch': 'master', 'winrepo_fallback': '', 'winrepo_ssl_verify': True, 'winrepo_user': '', 'winrepo_password': '', 'winrepo_insecure_auth': False, 'winrepo_privkey': '', 'winrepo_pubkey': '', 'winrepo_passphrase': '', 'winrepo_refspecs': ['+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*'], 'pidfile': '/tmp/kitchen/var/run/salt-minion.pid', 'range_server': 'range:80', 'reactor_refresh_interval': 60, 'reactor_worker_threads': 10, 'reactor_worker_hwm': 10000, 'engines': [], 'tcp_keepalive': True, 'tcp_keepalive_idle': 300, 'tcp_keepalive_cnt': -1, 'tcp_keepalive_intvl': -1, 'modules_max_memory': -1, 'grains_refresh_every': 0, 'minion_id_caching': True, 'minion_id_lowercase': False, 'minion_id_remove_domain': False, 'keysize': 2048, 'transport': 'zeromq', 'auth_timeout': 5, 'auth_tries': 7, 'master_tries': 1, 'master_tops_first': False, 'auth_safemode': False, 'random_master': False, 'cluster_mode': False, 'restart_on_error': False, 'ping_interval': 0, 'username': None, 'password': None, 'zmq_filtering': False, 'zmq_monitor': False, 'cache_sreqs': True, 'cmd_safe': True, 'sudo_user': '', 'http_connect_timeout': 20.0, 'http_request_timeout': 3600.0, 'http_max_body': 107374182400, 'event_match_type': 'startswith', 'minion_restart_command': [], 'pub_ret': True, 'proxy_host': '', 'proxy_username': '', 'proxy_password': '', 'proxy_port': 0, 'minion_jid_queue_hwm': 100, 'ssl': None, 'multifunc_ordered': False, 'beacons_before_connect': False, 'scheduler_before_connect': False, 'cache': 'localfs', 'salt_cp_chunk_size': 65536, 'extmod_whitelist': {}, 'extmod_blacklist': {}, 'minion_sign_messages': False, 'discovery': False, 'schedule': {}, 'ssh_merge_pillar': True, 'disabled_requisites': [], 'reactor_niceness': None, 'fips_mode': False, '__role': 'minion', '__cli': 'salt-call', 'beacons': {}, 'selected_output_option': 'state_output', 'fun': 'state.highstate', 'arg': [], 'config_dir': '/tmp/kitchen/etc/salt', 'args_stdin': False, 'hard_crash': False, 'no_parse': [], 'grains_run': False, 'doc': False, 'return': '', 'retcode_passthrough': True, 'print_metadata': False, 'skip_grains': False, 'refresh_grains_cache': False, 'log_level_logfile': 'warning', 'output_file_append': False, 'no_color': False, 'force_color': False, 'profiling_path': '/tmp/stats', 'profiling_enabled': False, 'log_datefmt_console': '%H:%M:%S', 'caller': True, 'pillar': {'TEMPLATE': OrderedDict([('lookup', OrderedDict([('master', 'template-master'), ('winner', 'lookup'), ('added_in_lookup', 'lookup_value')])), ('pkg', OrderedDict([('name', 'bash')])), ('service', OrderedDict([('name', 'systemd-journald')])), ('config', '/etc/template-formula.conf'), ('tofs', OrderedDict([('files_switch', ['any/path/can/be/used/here', 'id', 'roles', 'osfinger', 'os', 'os_family']), ('source_files', OrderedDict([('TEMPLATE-config-file-file-managed', ['example.tmpl.jinja']), ('TEMPLATE-subcomponent-config-file-file-managed', ['subcomponent-example.tmpl.jinja'])]))])), ('winner', 'pillar'), ('added_in_pillar', 'pillar_value')]), 'roles': ['foo', 'bar']}, '__fs_update': True, 'nodegroups': {}, 'jinja_env': {}, 'jinja_sls_env': {}, 'jinja_lstrip_blocks': False, 'jinja_trim_blocks': False}, 'pillar': {'TEMPLATE': OrderedDict([('lookup', OrderedDict([('master', 'template-master'), ('winner', 'lookup'), ('added_in_lookup', 'lookup_value')])), ('pkg', OrderedDict([('name', 'bash')])), ('service', OrderedDict([('name', 'systemd-journald')])), ('config', '/etc/template-formula.conf'), ('tofs', OrderedDict([('files_switch', ['any/path/can/be/used/here', 'id', 'roles', 'osfinger', 'os', 'os_family']), ('source_files', OrderedDict([('TEMPLATE-config-file-file-managed', ['example.tmpl.jinja']), ('TEMPLATE-subcomponent-config-file-file-managed', ['subcomponent-example.tmpl.jinja'])]))])), ('winner', 'pillar'), ('added_in_pillar', 'pillar_value')]), 'roles': ['foo', 'bar']}, 'saltenv': 'base', 'sls': 'foo', 'proxy': {}, 'renderers': <salt.loader.lazy.FilterDictWrapper object at 0x7f6786622a60>, 'rendered_sls': set(), 'tplpath': '/tmp/kitchen/var/cache/salt/minion/files/base/foo/init.sls', 'tplfile': 'foo/init.sls', 'tpldir': 'foo', 'tpldot': 'foo', 'slsdotpath': 'foo', 'slscolonpath': 'foo', 'sls_path': 'foo', 'slspath': 'foo'}
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/map.jinja' to resolve 'salt://foo/map.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/map.jinja' to resolve 'salt://foo/map.jinja'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/map.jinja'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/map.jinja'
       [DEBUG   ] In saltenv 'base', looking at rel_path 'foo/sub-import.jinja' to resolve 'salt://foo/sub-import.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/foo/sub-import.jinja' to resolve 'salt://foo/sub-import.jinja'
       [DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://foo/sub-import.jinja'
       [DEBUG   ] No dest file found
       [INFO    ] Fetching file from saltenv 'base', ** done ** 'foo/sub-import.jinja'
       [ERROR   ] Rendering exception occurred
       Traceback (most recent call last):
         File "/usr/lib/python3.8/site-packages/salt/utils/templates.py", line 506, in render_jinja_tmpl
           output = template.render(**decoded_context)
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
           self.environment.handle_exception()
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
           raise rewrite_traceback_stack(source=source)
         File "<template>", line 4, in top-level template code
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1412, in make_module
           return TemplateModule(self, ctx)
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1542, in __init__
           body_stream = list(template.root_render_func(context))  # type: ignore
         File "/tmp/kitchen/var/cache/salt/minion/files/base/foo/map.jinja", line 1, in top-level template code
           {%- from "foo/sub-import.jinja" import subdata %}
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1412, in make_module
           return TemplateModule(self, ctx)
         File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1542, in __init__
           body_stream = list(template.root_render_func(context))  # type: ignore
         File "/tmp/kitchen/var/cache/salt/minion/files/base/foo/sub-import.jinja", line 1, in top-level template code
           {% set subdata = salt["pillar.get"]("foo") %}
         File "/usr/lib/python3.8/site-packages/jinja2/sandbox.py", line 303, in getitem
           return obj[argument]
       jinja2.exceptions.UndefinedError: 'salt' is undefined
       
       During handling of the above exception, another exception occurred:
       
       Traceback (most recent call last):
         File "/usr/lib/python3.8/site-packages/salt/utils/templates.py", line 263, in render_tmpl
           output = render_str(tmplstr, context, tmplpath)
         File "/usr/lib/python3.8/site-packages/salt/utils/templates.py", line 514, in render_jinja_tmpl
           raise SaltRenderError("Jinja variable {}{}".format(exc, out), buf=tmplstr)
       salt.exceptions.SaltRenderError: Jinja variable 'salt' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/sub-import.jinja(1):
       ---
       {% set subdata = salt["pillar.get"]("foo") %}    <======================
       ---
       [CRITICAL] Rendering SLS 'base:foo' failed: Jinja variable 'salt' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/sub-import.jinja(1):
       ---
       {% set subdata = salt["pillar.get"]("foo") %}    <======================
       ---
       [DEBUG   ] Using pkg_resources to load entry points
       [DEBUG   ] LazyLoaded highstate.output
       local:
           Data failed to compile:
       ----------
           Rendering SLS 'base:foo' failed: Jinja variable 'salt' is undefined
       /tmp/kitchen/var/cache/salt/minion/files/base/foo/sub-import.jinja(1):
       ---
       {% set subdata = salt["pillar.get"]("foo") %}    <======================
       ---
salt-call --local --versions-report
Salt Version:
          Salt: 3004+0na.38906ff
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.8.11 (default, Aug 10 2021, 00:29:46) [GCC]
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 21.0.2
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.3
 
System Versions:
          dist: opensuse-tumbleweed 20210824 
        locale: utf-8
       machine: x86_64
       release: 5.10.0-8-amd64
        system: Linux
       version: openSUSE Tumbleweed 20210824 

@baby-gnu
Copy link

As I don't fully understand the code, I'm wondering few things:

  • if it's not an issue with passing context in globals and as .render() argument? My guess would be to pass things like salt, pillar, grains and opts as globals and context as .render() argument 🤔
  • Is the rendering of imported files done with the same engine? I added some manual logging to salt.utils.templates.render_jinja_tmpl() as we can see in the previous rendering log of foo/init.sls but that logging is not done for the rendering of foo/map.jinja neither for foo/sub-import.jinja

I don't really see how to ask jinja2 developpers what's going one without being rude to force them to look at salt code.

I don't see obvious hints in Jinja2 3.0 changelog, maybe that message about the use of globals but as I don't masterise the code I'm just wondering ;-)

That's all I can find.

baby-gnu added a commit to eole/template-formula that referenced this issue Aug 31, 2021
A change in Jinja2 3.0 cause troubles in rendering templates where
salt special variables are available only on first import but not
subsequent ones (see saltstack/salt#60188)

We could workaround that bug by explicitly import jinja libraries and
load YAML files `with context`.

* TEMPLATE/map.jinja: import `libmapstack.jinja` and `post-map.jinja`
  with context.

* TEMPLATE/libmapstack.jinja: import `libmatchers.jinja` with context.
  Load YAML files with context.

* TEMPLATE/libmatchers.jinja: import `libsaltcli.jinja` with context.
baby-gnu added a commit to eole/template-formula that referenced this issue Aug 31, 2021
A change in Jinja2 3.0 cause troubles in rendering templates where
salt special variables are available only on first import but not
subsequent ones (see saltstack/salt#60188)

We could workaround that bug by explicitly import jinja libraries and
load YAML files `with context`.

* TEMPLATE/map.jinja: import `libmapstack.jinja` and `post-map.jinja`
  with context.

* TEMPLATE/libmapstack.jinja: import `libmatchers.jinja` with context.
  Load YAML files with context.

* TEMPLATE/libmatchers.jinja: import `libsaltcli.jinja` with context.
@garethgreenaway
Copy link
Contributor

Looks like the fix in #60811 solves this issue in additional to another one.

@myii
Copy link
Contributor

myii commented Sep 2, 2021

This regression has been fixed going forward but there are still issues across various platforms, which I have shown a breakdown for in #60811 (comment).

Distro master tiamat 3003.2 3003.1 3002.6 3001.7 3000.9
Arch Linux git stable git git
Fedora 33 git git
Fedora 34 git git
Gentoo (latest) git stable git git
Gentoo (systemd) git stable git git
openSUSE Leap 15.2 git git git
openSUSE Leap 15.3 git git git
openSUSE Tumbleweed git stable git

saltstack-formulas-github pushed a commit to netmanagers/salt-image-builder that referenced this issue Apr 3, 2022
Check for problems associated with this bug:

* saltstack/salt#60188
  - Affects use of `grains`, `opts`, `pillar` & `salt` in Jinja.

Fix was first available in `3004`:

* saltstack/salt#60811

Use tests to apply the Jinja2 downgrade only where necessary
(and to ensure that it is actually working).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases. severity-high 2nd top severity, seen by most users, causes major problems Silicon v3004.0 Release code name
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants