My Playbook execution is not stopping in case of failure

I have an Ansible task in my playbook for api automation, where i have looped the payloads.
Here I am expecting to stop the playbook execution whenever there is a module.fail_json() called during an execution. But currently, the playbook does not stop execution. I have tried any_errors_fatal: true but this is not working in my case.

    - name: Configure user details
      user_details:
        ip_address: "{{ server_address }}"
        token: "{{  token }}"
        request_payload: "{{ item }}"  
      loop: "{{ users.request_payloads }}"
      loop_control:
        label: "{{ item.alias }}"
      register: results

If you’re running Ansible 2.18 or later: use break_when: "{{ results.failed }}" in the loop_control.

2 Likes