saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
13.98k stars 5.47k forks source link

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

Open amalaguti opened 1 week ago

amalaguti commented 1 week ago

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