mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
bced8715cd
commit
746ea64d30
3 changed files with 36 additions and 1 deletions
|
@ -430,11 +430,13 @@ class TaskExecutor:
|
||||||
|
|
||||||
# Read some values from the task, so that we can modify them if need be
|
# Read some values from the task, so that we can modify them if need be
|
||||||
if self._task.until:
|
if self._task.until:
|
||||||
retries = self._task.retries + 1
|
retries = self._task.retries
|
||||||
if retries is None:
|
if retries is None:
|
||||||
retries = 3
|
retries = 3
|
||||||
elif retries <= 0:
|
elif retries <= 0:
|
||||||
retries = 1
|
retries = 1
|
||||||
|
else:
|
||||||
|
retries += 1
|
||||||
else:
|
else:
|
||||||
retries = 1
|
retries = 1
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
- { role: test_changed_when, tags: test_changed_when }
|
- { role: test_changed_when, tags: test_changed_when }
|
||||||
- { role: test_failed_when, tags: test_failed_when }
|
- { role: test_failed_when, tags: test_failed_when }
|
||||||
- { role: test_handlers, tags: test_handlers }
|
- { role: test_handlers, tags: test_handlers }
|
||||||
|
- { role: test_until, tags: test_until }
|
||||||
- { role: test_copy, tags: test_copy }
|
- { role: test_copy, tags: test_copy }
|
||||||
- { role: test_stat, tags: test_stat }
|
- { role: test_stat, tags: test_stat }
|
||||||
- { role: test_template, tags: test_template }
|
- { role: test_template, tags: test_template }
|
||||||
|
|
32
test/integration/roles/test_until/tasks/main.yml
Normal file
32
test/integration/roles/test_until/tasks/main.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
- shell: python -c "import tempfile; print(tempfile.mkstemp()[1])"
|
||||||
|
register: tempfilepath
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
until_tempfile_path: "{{ tempfilepath.stdout }}"
|
||||||
|
|
||||||
|
- name: loop with default retries
|
||||||
|
shell: echo "run" >> {{ until_tempfile_path }} && wc -w < {{ until_tempfile_path }} | tr -d ' '
|
||||||
|
register: runcount
|
||||||
|
until: runcount.stdout | int == 3
|
||||||
|
delay: 0.01
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: runcount.stdout | int == 3
|
||||||
|
|
||||||
|
- file: path="{{ until_tempfile_path }}" state=absent
|
||||||
|
|
||||||
|
- name: loop with specified max retries
|
||||||
|
shell: echo "run" >> {{ until_tempfile_path }}
|
||||||
|
until: 1==0
|
||||||
|
retries: 5
|
||||||
|
delay: 0.01
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: validate output
|
||||||
|
shell: wc -l < {{ until_tempfile_path }}
|
||||||
|
register: runcount
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: runcount.stdout | int == 6 # initial + 5 retries
|
||||||
|
|
||||||
|
- file: path="{{ until_tempfile_path }}" state=absent
|
Loading…
Reference in a new issue