Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/ses_rule_set/tasks/obtain-lock-wrapper.yaml

raw
1 # ============================================================
2 # Do While loops cannot be used on task includes.
3 # See: https://github.com/ansible/ansible/issues/17098
4 #
5 # So as a workaround we use a regular loop to repeatedly attempt
6 # obtaining a lock.
7 #
8 # For this to work we need to skip the subsequent iterations
9 # once we get a lock, and delay between iterations if we
10 # did not obtain the lock.
11 #
12 # This file encapsulates this logic to reduce the spam from
13 # skipped tasks in the ansible log.
14 # ============================================================
15
16 - include_tasks: obtain-lock.yaml
17 # Skip obtaining a lock if we've already succeeded in getting it
18 when: "not won_lock|default(False)|bool"
19
20 - name: Lock Retry Delay
21 wait_for:
22 # Add some random jitter to the delay to reduce lock contention
23 timeout: "{{ obtain_lock_delay_seconds + 15|random }}"
24 # Only delay if we're retrying, so skip the delay if we're
25 # on the last attempt or have got the lock
26 when: "obtain_lock_attempt < (max_obtain_lock_attempts - 1) and not won_lock|bool"