-
Notifications
You must be signed in to change notification settings - Fork 23.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loop_control "early exit" feature #62151
Conversation
Looks like a very nice way to handle these kind of loops! |
Not sure that these changes would fix #46203 I tested @bcoca's branch locally with this playbook: - hosts: localhost
gather_facts: false
tasks:
- name: testing block looping
block:
- debug:
msg: "{{ item }}"
loop:
- 1
- 2
- 3
loop_control:
until: item > 2 Which yields:
Am I missing something? |
Ah I see what I was missing, this fix would only apply to - hosts: localhost
gather_facts: false
tasks:
- name: testing inlcude looping
include_tasks: some_tasks.yml
loop:
- 1
- 2
- 3
loop_control:
until: item > 2 |
Can you guys please fix this, the people are really hoping for this feature. |
I've had some success using |
@bcoca is this still intended to be made a core feature? would be very useful to have, it makes a lot of sense to be able to break out of a loop based on any condition. |
probably, but not a priority right now |
remove loop var as normal exit would
fix accessing the loop_control FA via fattributes attr
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
* add a loop_control break_when directive to break out of a loop after any item * remove loop var as normal exit would * example usage: - name: generate a random password up to 10 times, until it matches the policy set_fact: password: "{{ lookup('password', '/dev/null', chars=character_set, length=length) }}" loop: "{{ range(0, 10) }}" loop_control: break_when: - password is match(password_policy) Co-authored-by: s-hertel <19572925+s-hertel@users.noreply.github.com>
ISSUE TYPE
posisbly fixes #46203 by providing 'until for includes'
COMPONENT NAME
core