Workaround for Updating Grain and pulling into a variable in concurrent state file #66465
Replies: 2 comments
-
So-called slots could postpone the insertion of the information into a state during the run. However, i believe, this path is not really suited to do (complex) logic on its own. Another path to a possible workaround is to modify your powershell script to return so-called "stateful" information. Only if the grain is updated return a |
Beta Was this translation helpful? Give feedback.
-
What are you trying to actually use the data in the grain for? There may be a better way to get and use the information than using jinja or grains. |
Beta Was this translation helpful? Give feedback.
-
I have a state file that calls a Powershell script. Inside of that script at the end, the output is set to a grain through this line:
salt-call grains.setval {grain_name} $output_variable
This works properly and the grain is set. When the second state file runs I'm trying to loop through that updated grain like below:
{% for grain in salt['grains.get']('grain_name').split(",") %} {{ grain }} {% endfor %}
I hadn't realized that Jinja is parsed first in Salt, so unsure of how I can get this to work with the updated value and not the previous value. Would anyone know some sort of workaround for this issue? Do I just need to try to use file creation, processing, and then reading to get this to work instead? Thank you to anyone's advice!
Beta Was this translation helpful? Give feedback.
All reactions