saltstack / saltstack/salt

[BUG] jinja sls variables like sls, slspath, tpldir are not loaded for saltcheck.run_state_tests

Open
#66,653 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
SLS Jinja variables described here
https://docs.saltproject.io/en/latest/ref/states/vars.html
are not available in the context for saltcheck.run_state_tests

At least the following ones do not seem to be resolved properly for saltcheck states
{{ tpldir }}
{{ slspath }}
{{ sls }}

Setup
Trying to use these variables to import a jinja map file that provides settings to be used in the saltcheck state.

{%- set tplroot = tpldir.split('/')[0] %}
{% from tplroot ~ "/map.jinja" import settings with context %}

The jinja template is not found due the variables return none.

A hardcoded string works fine

{% from"path_to_state/map.jinja" import settings with context %}

Steps to Reproduce the behavior
Create a jinja map file and a saltcheck state to use it, try importing the jinja map file using tpldir or slspath variables

Expected behavior
These variables should be loaded in a similar way than it's done for state.sls

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 with saltcheck.run_state_tests and compare its Jinja context with the state.sls behavior described in the linked SLS variables documentation. Reproduce the issue using a map.jinja import based on tpldir or slspath; done means those variables resolve and the import succeeds in a saltcheck state.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, testing-qa
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.