Abort execution of remaining task if certain condition is failed

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)