Abort execution of remaining task if certain condition is failed

Question:

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 error message and stop execution of ansible playbook.

Lets say I am running below command

My playbook look like this:-

playbook.yml:-

As I have mentioned in my last task comment. I am executing more than 10 task based on validParams and param1 different value. What I need here
if validParams is undefined then abort all execution and show error messages.

Is there any efficient way to do this . Please suggest me.

Answer:

You can use

It will go along with something like this

Leave a Reply