# Regarding not to proceed further if ansible task fails

**URL:** <https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407>\
**Category:** Ansible Project\
**Created:** [September 6, 2023, 3:22am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407 "2023-09-06T03:22:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 6, 2023, 3:22am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/1 "2023-09-06T03:22:49Z")

</div>

Hi All,

When I tried to download packages from jfrog repository, If it gets downloaded, it is okay. But if it is unable to download, we should not proceed further to execute other tasks.

How to write ansible task?

If we use register and based on the condition, shall we stop to expect tasks?

Can you please help me?

---

<div class="post-metadata">

**Author:** ![skratbag](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/skratbag/32/4836_2.png) [@skratbag](https://forum.ansible.com/u/skratbag)\
**Post date:** [September 6, 2023, 9:56am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/2 "2023-09-06T09:56:04Z")

</div>

Hi Ashok,

The methods you need are here [https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_error\_handling.html](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_error_handling.html)

There are some good ideas on how to halt and abort a playbook if errors occur

Regards

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 6, 2023, 2:15pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/3 "2023-09-06T14:15:27Z")

</div>

Hi ,

Can someone help me?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 6, 2023, 2:34pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/4 "2023-09-06T14:34:39Z")

</div>

This is the default behavior, if task #1 fails, subsequent tasks will  
not run for that host. In the previous response they point you on how  
to continue on error, the implication being the default is to stop on  
error.

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 6, 2023, 11:47pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/5 "2023-09-06T23:47:11Z")

</div>

Hi Brian

Noted and Thanks for your response.  
But, when we tried to download packages, the package is not available and then the task fails .

The next tasks also executed and It does not come out of the script.

In that case, I have written a task to verify whether file exists or not and then any\_fail\_on\_error: true .

Is it correct?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [September 6, 2023, 11:52pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/6 "2023-09-06T23:52:38Z")

</div>

Hii

What you describe is nonstandard behaviour.  
Instead of guessing, please show us your playbook and any other relevant code.

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 8, 2023, 6:48am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/7 "2023-09-08T06:48:19Z")

</div>

Hi ,

The following script, which only skip the task and execute further:

 ![](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)

But, What I did : If the file doesn’t exist, it cannot proceed to execute tasks and cone out ofcthe script:

 ![](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)

Is it correct?

Can someone help me with this?

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 11, 2023, 3:50am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/8 "2023-09-11T03:50:09Z")

</div>

Hi All,

Can you please help?

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)  
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [September 11, 2023, 3:37pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/9 "2023-09-11T15:37:42Z")

</div>

I don’t wish to defend the horrid things that Google Groups does to pasted text, particularly where whitespace matters.

However, photos of text is about useless. For example, there’s no practical way to run a linter on pictures of text. It’s impossible to say with certainty that a task in a clipped photo is correct.

You’ve been working with these tasks now for almost a week. Is there any behavior you see that makes you think they don’t do what you expect? If so, then copy-and-past (not screenshots!) the evidence from the run log, include the relevant tasks, data, etc., and explain what you expect contrasted with what is actually happening.  
Otherwise, yes, it is correct! (?)

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 11, 2023, 11:53pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/10 "2023-09-11T23:53:22Z")

</div>

Hi ,

I have tried but it didn’t stop when task fails.

If we use failed\_when: true, it can work.

Can you please help?

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)  
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 12, 2023, 3:08am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/11 "2023-09-12T03:08:54Z")

</div>

Hi Brian,

The logs are:

 ![](https://us1.discourse-cdn.com/ansible/original/2X/b/bb8551045faff67a98c39a3921373743c05c359f.jpeg)

Even if the task fails, it can proceed to execute further tasks . But don’t want that.

What I am trying to achieve is If the task fails, it will not proceed further to execute tasks and come out of the script

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)  
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)

---

<div class="post-metadata">

**Author:** ![skratbag](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/skratbag/32/4836_2.png) [@skratbag](https://forum.ansible.com/u/skratbag)\
**Post date:** [September 12, 2023, 4:23am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/12 "2023-09-12T04:23:48Z")

</div>

From the documentation

By default, Ansible continues to execute tasks as long as there are hosts that have not yet failed. You might like to set a maximum failure percentage or similar.

Do you have this running on multiple hosts? or is it on a single host?

[https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_error\_handling.html](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_error_handling.html)

Regards  
David

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)  
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [September 12, 2023, 12:37pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/13 "2023-09-12T12:37:32Z")

</div>

I don’t know if this was mentioned at all, but have you looked at the meta module? I used it to break out of a play when something failed.

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/meta\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/meta_module.html)

–John

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/b/b5391f926f4d45d639d202c55e95076874572caa.jpeg)  
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/7/746a17df1881d9151d71ea21c638cb3ce0456522.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 12, 2023, 2:12pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/14 "2023-09-12T14:12:53Z")

</div>

from the output you have EXPLICIT ignores to the failures, that is why Ansible is continuing to more tasks, remove the ignores if you don’t want the failure to be ignored.

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 13, 2023, 7:43am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/15 "2023-09-13T07:43:30Z")

</div>

Hi Brian,

Did not configure the ignore\_errors in playbook

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 13, 2023, 7:46am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/16 "2023-09-13T07:46:11Z")

</div>

![](https://us1.discourse-cdn.com/ansible/original/2X/9/9fea7cd6c1dc70319efc69665423d6a8f64c2c70.jpeg)

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 13, 2023, 7:46am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/17 "2023-09-13T07:46:28Z")

</div>

![](https://us1.discourse-cdn.com/ansible/original/2X/5/57f99518c9cb0cfbea25f8b13d4c7e25ecbbaf85.jpeg)

> **(attachments)**
>
> ![image_6487327.JPG](https://us1.discourse-cdn.com/ansible/original/2X/9/9fea7cd6c1dc70319efc69665423d6a8f64c2c70.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 13, 2023, 2:05pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/18 "2023-09-13T14:05:16Z")

</div>

Not in the part you are showing, but the output you showed has `ignoring ..` which you only get with that keyword.

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [September 13, 2023, 2:13pm UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/19 "2023-09-13T14:13:54Z")

</div>

You didn’t show any playbook so far, just (fuzzy pictures of computer screens with) task files that are included.  
If you can post the TEXTUAL version of the playbook that includes them.

Please do not post any more photos of computer screens… just the actual text.  
So: no pictures - just text.

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [September 14, 2023, 1:25am UTC](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407/20 "2023-09-14T01:25:06Z")

</div>

Hi All,

PFA for the ansible playbook

> **(attachments)**
>
> [deploy\_tasks\_main (1).yml](https://forum.ansible.com/uploads/short-url/A6I1HEVRhUIkT14OoG7uowmIc1g.yml) (7.81 KB)

[Next page](https://forum.ansible.com/t/regarding-not-to-proceed-further-if-ansible-task-fails/38407.md?page=2)
