Saltostat variables after state

I have a question about SaltStack variables. I want to set the folder name, for example:

{% set exim4_folder = salt['cmd.run']('ls /tmp | grep exim4') %}

but the folder that I am trying to retrieve is not reachable to the state that I was running before this assignment:

download_source_code:
  cmd.run:
    - cwd: /tmp
    - names:
      - apt-get -y source exim4
      - apt-get -y build-dep exim4

Is there any way to tell salt to run this assignment after running "download_source_code"?

+4
source share
1 answer

The problem you will encounter is that all the jinja sections of your sls file will be evaluated before any of the states of the Yaml Salt is evaluated.

So your 'ls / tmp | grep exim4 'will always be executed before your state is executed download_source_code.

+1
source

Source: https://habr.com/ru/post/1543966/


All Articles