Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct computation for range end has been added (#975)
fix: correct computation for range end has been added Depends-On: #977 playbook: --- - hosts: localhost vars: ansible_test_split_in: 3 number_entries: 10 tasks: - set_fact: _iter_by: "{{ (number_entries|int / ansible_test_split_in)|round(0, 'ceil')|int }}" - set_fact: _start_at: "{{ (_iter_by|int * ansible_test_do_number|int) - _iter_by|int }}" - set_fact: _end_at: "{{ _start_at|int + _iter_by|int }}" - debug: msg: "iter: {{ _iter_by }}, start: {{ _start_at }}, end: {{ _end_at }}" produces: ➭ for i in {1..3}; do ansible-playbook a.yaml -e ansible_test_do_number=$i 2>&1; done | grep iter iter: 4, start: 0, end: 4 iter: 4, start: 4, end: 8 iter: 4, start: 8, end: 12 and with the fix: ➭ for i in {1..3}; do ansible-playbook a.yaml -e ansible_test_do_number=$i 2>&1; done | grep iter iter: 4, start: 0, end: 3 iter: 4, start: 4, end: 7 iter: 4, start: 8, end: 9
- Loading branch information