A specific case leading to a more general question: I have a salt formula that looks like this:
formula/
init.sls
some_other_state.sls
defaults.yaml
As part of both sls's behavior I want them to load defaults.yaml into a dict. I can do it this way in either of them:
{%- import_yaml formula/defaults.yaml as defaults %}
...but this hardcodes the location of the formula relative to the base of the salt tree, and will break if the tree is ever restructured and the formula moved to (say) a nested directory.
I tried this instead:
{%- import_yaml (slspath + "/defaults.yaml") as defaults %}
This works for init.sls but not for some_other_state.sls; the reason is that slspath
expands to the containing directory for the former but the full path for the latter.
What I really want is some equivalent of slspath that always expands to "the directory containing the currently-running sls." I can then specify whatever path I need relative to that.
Does such a variable exist, and if so, what is it?