60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
---
|
|
- name: Check for runner-provided bootstrap image archives
|
|
stat:
|
|
path: "{{ playbook_dir }}/../outputs/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
|
|
delegate_to: localhost
|
|
become: false
|
|
register: bootstrap_image_archive_stats
|
|
loop: "{{ bootstrap_prepull_images }}"
|
|
|
|
- name: Ensure remote bootstrap image archive directory exists
|
|
file:
|
|
path: /tmp/bootstrap-image-archives
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Copy runner-provided bootstrap image archives
|
|
copy:
|
|
src: "{{ item.stat.path }}"
|
|
dest: "/tmp/bootstrap-image-archives/{{ item.item | regex_replace('[/:]', '_') }}.tar"
|
|
mode: "0644"
|
|
loop: "{{ bootstrap_image_archive_stats.results }}"
|
|
loop_control:
|
|
label: "{{ item.item }}"
|
|
when: item.stat.exists
|
|
|
|
- name: Import or pull bootstrap images into containerd
|
|
shell: |
|
|
if /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
|
|
echo "already present"
|
|
exit 0
|
|
fi
|
|
|
|
archive="/tmp/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
|
|
if [ -s "${archive}" ]; then
|
|
for attempt in 1 2 3; do
|
|
if /usr/local/bin/ctr -n k8s.io images import "${archive}" && /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
|
|
echo "imported image"
|
|
exit 0
|
|
fi
|
|
|
|
sleep 10
|
|
done
|
|
fi
|
|
|
|
for attempt in 1 2 3 4 5; do
|
|
if timeout 180s /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 }}"
|
|
changed_when: "'imported image' in bootstrap_image_pull.stdout or 'pulled image' in bootstrap_image_pull.stdout"
|