Ansible task that retries

Categories: English

---
- name: Run a local task 
  hosts: 127.0.0.1
  connection: local
  tasks:
      - name: loop the loop
        uri:
            url: http://www.someurl.example.com/status.html
            return_content: yes
        register: foo
        until: foo.content.find("monkeys") != -1
        delay: 1
        retries: 5

The task can be whatever you want: I used uri but it’s more usually shell or something like that. The main thing is that you need to use register so you’ll have something to check in the until: condition.