# Playbook gives inconsistent results

**URL:** <https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987>\
**Category:** Ansible Project\
**Created:** [July 14, 2017, 1:07pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987 "2017-07-14T13:07:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [July 14, 2017, 1:07pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987/1 "2017-07-14T13:07:31Z")

</div>

I’ve got a multi-task playbook - if I run it against Servers A & B, all tasks run for both servers. If I run it against just B it fails at the first task and stops.

My view is if you run a playbook against a server you should get consistent results.

I raised this as a Bug in GitHub but it was closed as “That’s the way it is”. No disrespect to the Dev who closed that but I want to get other opinions on this.

MKPhil

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [July 14, 2017, 1:10pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987/2 "2017-07-14T13:10:48Z")

</div>

There's no way to figure out what's happening from just that description,  
did you provide a test case on github?

---

<div class="post-metadata">

**Author:** ![Mathias\_Ettinger](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mathias\_Ettinger](https://forum.ansible.com/u/Mathias_Ettinger)\
**Post date:** [July 14, 2017, 1:18pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987/3 "2017-07-14T13:18:04Z")

</div>

Can you share a link to the issue that was closed or at least share the playbook so we can have a chance understanding what is going on.

---

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [July 14, 2017, 3:40pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987/4 "2017-07-14T15:40:44Z")

</div>

Here’s a basic Playbook which has this functionality. All tasks run for servers A and B but fails when run only against B where B is a server that cannot be contacted. My point is that if I run this against Server B I should get the same result _regardless_ of what other servers I run it against.

`

```auto
---
- name: Check Servers
  gather_facts: false
  hosts: windows
  tasks:
    - name: Check server with win_ping
      win_ping:
      register: result
      ignore_errors: yes
    - meta: clear_host_errors
    - debug:
        msg: "{{ inventory_hostname | quote }} {{ result | default() }}"
...

```

`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 14, 2017, 4:07pm UTC](https://forum.ansible.com/t/playbook-gives-inconsistent-results/24987/5 "2017-07-14T16:07:19Z")

</div>

As I mentioned in the ticket, this is not inconsistent, this is just  
how the rules for fatal and non fatal errors work. Since running only  
B gets a fatal error (no hosts left in play to continue) the play ends  
before the `meta` task, when any other host is left (like when you add  
A to the mix) the error is non-fatal and the `meta` task gets  
executed.

if you just want consistency, this will make your play behave the same  
in both cases:

- name: Check Servers  
&nbsp;&nbsp;gather\_facts: false  
&nbsp;&nbsp;hosts: windows  
&nbsp;&nbsp;any\_errors\_fatal: True  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: Check server with win\_ping  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;win\_ping:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: result  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: yes  
&nbsp;&nbsp;&nbsp;&nbsp;- meta: clear\_host\_errors  
&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ inventory\_hostname | quote }} {{ result | default() }}"

But that is not very useful, if you actually want to get the debug  
messages in all cases I recommend the following:

- name: Check Servers  
&nbsp;&nbsp;gather\_facts: false  
&nbsp;&nbsp;hosts: windows  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- block:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Check server with win\_ping  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;win\_ping:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: result  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;always:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ inventory\_hostname | quote }} {{ result | default() }}"
