how to handle error in salt commands? how to add error validation for each command

14 views
Skip to first unread message

bindh...@gmail.com

unread,
Jan 20, 2018, 7:59:38 PM1/20/18
to Salt-users
How to add error validation for each command ?

foreg: 

suppose i have to run 2 commands,

test:
  cmd.run:
    - names:
       - Stop-Process -Name NvtServer -Force -erroraction silentlycontinue; exit 0
    - shell: 'powershell'

push-script:
  file.managed:
     - name: C:\test.py
     - source: salt://test.py 


if first command fails no need to run the second command, want to execute the 2 nd command only after the success execution of first command 

how to handle error for each commands in state file? 


Amse Master

unread,
Jan 21, 2018, 8:46:16 AM1/21/18
to Salt-users
You can use the "failhard" option to have the state execution stop on failure:

https://docs.saltstack.com/en/latest/ref/states/failhard.html#state-level-failhard

Reply all
Reply to author
Forward
0 new messages