saltstack / saltstack/salt

[BUG] All function from `jinja` module do not support saltenv

Open
#59,300 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
All the function of the jinja execution module do not support saltenv argument and also do not use the saltenv from the config

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info).

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)

Just try to use any function of the jinja execution module when your file sit in a saltenv different from base

E.g.:
minion config

file_root:
  my-env:
  - /srv/my-env
saltenv: my-env

A simple yaml file

# /srv/my-env/my-formula/foo.yaml
abc: def

Trying to get this yaml using jinja.import_yaml is impossible since it does not sit in base saltenv

Expected behavior
Honor saltenv from minion config and ideally add a saltenv argument to the function

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3002.2
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 17.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4
 
System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-1127.el7.x86_64
        system: Linux
       version: CentOS Linux 7 Core

Additional context
IMHO jinja function should have the same behavior as slsutil.renderer function (and maybe this module should directly use the slsutil.renderer function)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the jinja execution module and compare its behavior with the mentioned slsutil.renderer function. Reproduce the issue with the provided my-env saltenv configuration and foo.yaml example, then determine how saltenv configuration and an explicit argument should be handled. Done means jinja functions work with files outside the base saltenv and the behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.