#netapp.ontap.na_ontap_rest_cli issue with loop and register results HELP!

1 messages · Page 1 of 1 (latest)

stray haven
#

Ansible Gurus,
I am in need of some assistance with using the na_ontap_rest_cli module to ping a list of ip addresses and quit the loop once the first non live ip address is found based on the registered ping_result var which would look like the following:

ping_result: {'changed': True, 'msg': {'cli_output': '10.224.9.2 is alive '}, 'failed': False}
or
ping_result: {'changed': True, 'msg': {}, 'failed': False}

The issue is when the loop encounters the 2nd ping result above, the loop does not terminate

The sample playbook is attached.

inner maple
#

I don't think it is possible to terminate a loop early in Ansible. You will have to go through all iterations and check the result in a second step.

stray haven
wide rivet
#

You can loop on an 'include_tasks:' and fail the task in a block/rescue

#

Don't really need the register: var either - it's never referenced