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] v5.0.0+ failed on Raspberry Pi 4 with error "Jinja variable 'opts' is undefined" #236

Closed
nikAizuddin opened this issue Jul 23, 2021 · 2 comments
Labels

Comments

@nikAizuddin
Copy link

Your setup

Formula commit hash / release tag

v5.0.2-14-g9ef82f4.

Version v4.3.8 doesn't have this issue. But starting on v5.0.0+, this issue occur Raspberry Pi 4 (x86_64 machines are not affected).

Versions reports (master & minion)

I have tested v5.0.2-14-g9ef82f4 with 3 different masterless minions. Out of 3, only 1 minion failed.

This is the minion that failed, which is running on Raspberry Pi 4:

Salt Version:
          Salt: 3003.1

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: 1.1.3
       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.9.5 (default, May 11 2021, 08:20:37)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.1.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4

System Versions:
          dist: ubuntu 21.04 hirsute
        locale: utf-8
       machine: aarch64
       release: 5.11.0-1015-raspi
        system: Linux
       version: Ubuntu 21.04 hirsute

This minion has no problem, running on WSL2:

Salt Version:
          Salt: 3003

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.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.10 (default, Jun  2 2021, 10:49:15)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 22.0.3
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 20.04 focal
        locale: utf-8
       machine: x86_64
       release: 5.4.72-microsoft-standard-WSL2
        system: Linux
       version: Ubuntu 20.04 focal

This minion also has no problem, running on Fedora:

Salt Version:
          Salt: 3002.2
 
Dependency Versions:
          cffi: 1.14.1
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.9.6 (default, Jul 16 2021, 00:00:00)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.1.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: fedora 33 
        locale: utf-8
       machine: x86_64
       release: 5.13.4-100.fc33.x86_64
        system: Linux
       version: Fedora 33

Pillar / config used

I didn't create pillar files for this test. However, this is /etc/salt/minion from my Raspberry Pi 4:

file_client: local
log_level: 'info'
log_level_logfile: 'info'
pillar_roots:
  base:
    - /srv/pillar
file_roots:
  base:
    - /srv/salt
    - /home/ubuntu/Documents/template-formula
use_superseded:
  - module.run

Bug details

Describe the bug

The following error message appear whenever I try to apply any state.sls states, such as TEMPLATE.config:

local:
    Data failed to compile:
----------
    Rendering SLS 'base:TEMPLATE.config.file' failed: Jinja variable 'opts' is undefined
/var/cache/salt/minion/files/base/TEMPLATE/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' %}
[...]
---

Steps to reproduce the bug

Use Raspberry Pi 4.

Clone this template:

git clone https://github.com/saltstack-formulas/template-formula.git

Add path to template-formula into your /etc/salt/minion.

Then, apply TEMPLATE.config:

sudo salt-call -l debug state.sls TEMPLATE.config

Expected behaviour

Error message Rendering SLS 'base:TEMPLATE.config.file' failed: Jinja variable 'opts' is undefined should not occur.

Attempts to fix the bug

I haven't done any attempts yet, but I think the problem comes from TEMPLATE/libmatchers.jinja?

Additional context

@myii
Copy link
Member

myii commented Jul 23, 2021

@nikAizuddin Thanks for the report. You're hitting this issue here:

I've linked directly to my comment with the workaround. We're waiting on a fix from the Salt team.

@nikAizuddin
Copy link
Author

ah, i see. I have to downgrade jinja2 to version 2.11.3:

sudo python3 -m pip install jinja2==2.11.3

Thanks @myii . I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants