Abort execution of remaining task if certain condition is failed

前端 未结 3 1319
悲&欢浪女
悲&欢浪女 2020-12-23 20:04

I want to abort execution of remaining task if certain condition is failed. and display proper error message.

So instead of skipping remaining task I want to show er

3条回答
  •  没有蜡笔的小新
    2020-12-23 20:22

    You can use

    • assert https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assert_module.html
    • or fail https://docs.ansible.com/ansible/latest/collections/ansible/builtin/fail_module.html

    It will go along with something like this

            #check if params are invalid then abort below all tasks.  
            - name: 'check parm is null or invalid' 
              fail: msg="Please enter correct Params"
              when: "param1 is not defined or param2 is not defined " ## whatever condition you want
    

提交回复
热议问题