Saltstack waits for a file to appear

Is it possible to do the same in Saltsack, but with built-in functionality (no powershell workaround)?

installation:
cmd.run:
- name: ./installation_script

wait for installation:
cmd.run:
 - name: powershell -command "Start-Sleep 10"
 - unless: powershell -command "Test-Path @('/path/to/file/to/appear')"

      

+3


source to share


1 answer


Unfortunately, there is no better way to do this in the current version of salt. But in the next release of Nitrogen, the logic is added retry

.

I would do it in this version.

installation:
  cmd.run:
    - name: ./installation_script

wait for installation:
  cmd.run:
    - name: Test-Path @('/path/to/file/to/appear')
    - retry:
      - attempts: 15
      - interval: 10
      - until: True
    - shell: powershell

      



And that will keep running the test path until it exits with exit code 0 (or whatever powershell equivalent)

https://docs.saltstack.com/en/develop/ref/states/requisites.html#retrying-states

Daniel

+6


source







All Articles