Error handling in do..until loops

31 views
Skip to first unread message

Trond Hindenes

unread,
Jun 18, 2015, 8:07:03 PM6/18/15
to ansible...@googlegroups.com
Hi all,
I'm trying to write a play I'm going to use as part of a windows system reboot "role". I plan to ping the Windows node's WinRM port using curl until it's responding.

If the system is down, the curl command will result in an error (exit code 7).

Here's my play:
---
- name: Wait for windows reboot
  hosts: windows
  gather_facts: False
  tasks:
    - shell: 'curl -s -f -k <lots of stuff snipped away>'
      register: result2
      until: result2.stdout.find("http://www.w3.org/2003/05/soap-envelope")
      retries: 10
      delay: 10
      delegate_to: 127.0.0.1
      ignore_errors: yes
      changed_when: False

I'd like it to ignore the error from curl, and just keep trying until it gets the correct soap header back. This play is failing on the first run if the node is down, and not retrying at all.

Anyone have any pointers on how to do this?

Reply all
Reply to author
Forward
0 new messages