fix: make Ansible reruns faster and idempotent
Deploy Cluster / Terraform (push) Successful in 28s
Deploy Cluster / Ansible (push) Has been cancelled

This commit is contained in:
2026-04-24 11:44:11 +00:00
parent c89c31adea
commit 3f52bad854
4 changed files with 72 additions and 18 deletions
@@ -1,19 +1,33 @@
---
- name: Pre-pull bootstrap images into containerd
command: timeout 180s /usr/local/bin/ctr -n k8s.io images pull {{ item }}
shell: |
if /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
echo "already present"
exit 0
fi
for attempt in 1 2 3; do
if timeout 120s /usr/local/bin/ctr -n k8s.io images pull "{{ item }}"; then
echo "pulled image"
exit 0
fi
sleep 10
done
exit 1
args:
executable: /bin/bash
register: bootstrap_image_pull
loop: "{{ bootstrap_prepull_images }}"
retries: 6
delay: 20
until: bootstrap_image_pull.rc == 0
changed_when: bootstrap_image_pull.rc == 0
changed_when: "'pulled image' in bootstrap_image_pull.stdout"
failed_when: false
- name: Report bootstrap images that did not pre-pull after retries
debug:
msg: >-
Best-effort bootstrap image pre-pull did not complete for {{ item.item }} after
{{ item.attempts | default(1) }} attempt(s): {{ item.stderr | default('no stderr') }}
3 attempt(s): {{ item.stderr | default('no stderr') }}
loop: "{{ bootstrap_image_pull.results | default([]) }}"
loop_control:
label: "{{ item.item }}"