mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 03:14:29 +00:00
28 lines
1.2 KiB
YAML
28 lines
1.2 KiB
YAML
---
|
|
|
|
- name: "Check if image {{ k3s_import_image.image }} already exists"
|
|
ansible.builtin.shell: "k3s ctr -n k8s.io images list -q | grep -q '^{{ k3s_import_image.image }}$'"
|
|
register: _k3s_image_check
|
|
changed_when: false
|
|
failed_when: false
|
|
when: k3s_import_image.image | default('') != ''
|
|
|
|
- name: "Copy image tarball {{ k3s_import_image.path | basename }} to k3s node"
|
|
ansible.builtin.copy:
|
|
src: "{{ k3s_import_image.path }}"
|
|
dest: "/tmp/{{ k3s_import_image.path | basename }}"
|
|
mode: "0644"
|
|
when: k3s_import_image.image | default('') == '' or _k3s_image_check.rc != 0
|
|
|
|
- name: "Import image {{ k3s_import_image.path | basename }} into k3s containerd"
|
|
ansible.builtin.command: k3s ctr -n k8s.io images import "/tmp/{{ k3s_import_image.path | basename }}"
|
|
register: _k3s_ctr_import
|
|
changed_when: "'unpacking' in _k3s_ctr_import.stdout"
|
|
when: k3s_import_image.image | default('') == '' or _k3s_image_check.rc != 0
|
|
|
|
- name: "Remove temporary tarball for {{ k3s_import_image.path | basename }}"
|
|
ansible.builtin.file:
|
|
path: "/tmp/{{ k3s_import_image.path | basename }}"
|
|
state: absent
|
|
when: k3s_import_image.image | default('') == '' or _k3s_image_check.rc != 0
|