> > > On Thu, 25 Jun 2020 06:51:12 -0700 (PDT) > > > Cade Lambert <[email protected] <javascript:>> wrote: > > > I'd like it to stop processing the loop at item=4, since that's the > > > first success.
> > This is not possible atm. All items in the loop will be processed. The > > details have already been discussed here > > https://groups.google.com/forum/#!topic/ansible-project/uJqSmkKTpZc > Ok, I tried the 'hack' ... Ugly but it works. There is no hack available to break a loop. All items of a loop will be processed atm. Wouldn't be better to test the registered results? For example - command: '[ "{{ item }}" -gt "3" ]' loop: "{{ range(1, 5 + 1)|list }}" register: result ignore_errors: true - set_fact: first: "{{ result.results| selectattr('rc', '==', 0)| map(attribute='item')| first }}" - debug: var: first gives first: '4' -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20200625175632.2394a2cf%40gmail.com.
pgpdhETDosBjb.pgp
Description: OpenPGP digital signature
