Saltstack: Pass jinja variable from a salt state file to an included salt state

saltstack

I have the case where I have 3 salt states A.sls, B.sls and C.sls of which only one will be applied on a host.
All 3 of them sets a jinja variable x to a specific value and then I want all 3 to call a mutual salt state D.sls which makes use of x.
How do I do this? I tried using include: D.sls but it is executed before I can set variable.

Best Answer

The trick was not to use the Salt "include" directive, but the jinja include as shown in this answer: Passing variables with include in salt-stack