When writing ansible playbook, there is a scene when a task should be delayed for seconds to run. But you do not know how long it should be. In this case, we want to delay this task for seconds, and retry it for several times.

Here is an example to archive that.

  - shell: echo "do something"; exit 1
    register: command_result
    retries: 5
    delay: 10
    until: command_result | success
blog comments powered by Disqus