prole/infrastructure/roles/k3s/tasks/import_images.yml

35 lines
1.1 KiB
YAML

---
- name: Wait for k3s containerd socket to be present
ansible.builtin.wait_for:
path: /run/k3s/containerd/containerd.sock
state: present
timeout: "{{ k3s_containerd_socket_wait_timeout | default(120) }}"
changed_when: false
- name: Verify k3s container runtime is available
ansible.builtin.command: k3s ctr -n k8s.io version
register: _k3s_ctr_version
changed_when: false
failed_when: false
retries: 12
delay: 5
until: _k3s_ctr_version.rc == 0
- name: Fail if k3s container runtime is not available
ansible.builtin.fail:
msg: >-
k3s/containerd is not ready on {{ inventory_hostname }}.
Expected /run/k3s/containerd/containerd.sock and a working `k3s ctr`.
Check the k3s service status and node networking, then retry the import.
when: _k3s_ctr_version.rc != 0
- name: Import image tarballs into k3s containerd
ansible.builtin.include_tasks: import_image.yml
loop: "{{ k3s_import_images }}"
loop_control:
loop_var: k3s_import_image
label: "{{ k3s_import_image.path | basename }}"
when:
- (k3s_import_images | length) > 0