Do-until loop with an include task

1,055 views
Skip to first unread message

Chip Selden

unread,
Feb 24, 2015, 1:21:28 PM2/24/15
to ansible...@googlegroups.com
Community,

I'm trying to loop through a tasks script until a task check does not fail. This is what I'd like to use:

- name: Retry startup
  include: retry.yml
  when: check|failed
  retries: 3
  until: not check|failed

The retry.yml script registers 'check' again to verify that the startup is successful. However, upon execution, only the first task in the retry.yml script gets run, the rest of the tasks are skipped entirely. Is this a bug/deficiency of the "include" module? I'd like the whole script to be retried instead of the first task. The method below functions, and does what I want but is not as clean.

- name: Retry startup 
  include: retry.yml
  when: check|failed

- name: Retry startup 
  include: retry.yml
  when: check|failed

- name: Retry startup 
  include: retry.yml
  when: check|failed

I know that ansible does not allow inlcude tasks to use 'with_items' or any sort of looping, I assume this is related.

Thanks,
Chip

Brian Coca

unread,
Feb 25, 2015, 8:26:55 AM2/25/15
to ansible...@googlegroups.com

Yes, this won't work. Include is not a module, more like a preprocessing macro.

Reply all
Reply to author
Forward
0 new messages