Imagine this Ansible code that is supposed to set the task as failed only when the command returns a value different than 0 or 1.
- shell: some-command
register: result
failed_when: result.rc not in [0, 1] or 'err' in result.stdout_lines
How it would look the variant that does use a with_items loop? As you probably know for these result structure would contain a results
dictionary which stores the results of each item.
Sadly for us, we want to decide the failed status by looking at all.
- shell: "{{ item }}"
register: result
failed_when: ????
with_items:
- ls
- df