Execute ansible include_tasks until a certain condition is met (kind of while until loop)
17:49 01 Oct 2020

I want to execute an include tasks list until a certain condition is met, I do not have a fixed loop but execution depends upon a condition.

A sample play below

Tasks list playbook tasks.yml

---

- name: "inc test-var {{ test_var }}"
  set_fact:
    test_var: "{{ test_var | int + 1  }} "

parent playbook parent.yml

---

- hosts: all
  gather_facts: no

  tasks:
    - set_fact:
        test_var: '1'
        req_var: '4'

    - name: "Test multi run of task"
      include_tasks: ./includes/tasks.yml
      register: versions_result
      until: test_var is version(req_var, '<')
      retries: 5

here I am expecting parent.yml tasks to run multiple times but it only run once. Could some one point out what I am doing wrong and how to run a task multiple times until a condition is met.

Cheers,

ansible until-loop