use include_tasks to avoid empty json error for Set node_images (crictl) task
parent
7ba6750fd5
commit
08a0541c75
|
@ -16,35 +16,20 @@
|
||||||
- download
|
- download
|
||||||
- upload
|
- upload
|
||||||
|
|
||||||
- name: Download | Get list of images on the node
|
- name: Download | Generate a list of information about the images on a node
|
||||||
|
command: "{{ image_info_command }}"
|
||||||
|
register: node_images_raw
|
||||||
|
changed_when: false
|
||||||
|
check_mode: false
|
||||||
|
when:
|
||||||
|
- not (download_always_pull or skip_downloads) | default(false)
|
||||||
|
|
||||||
|
- name: Download | Set node_images
|
||||||
|
include_tasks: "{{ include_file }}"
|
||||||
|
vars:
|
||||||
|
include_file: "set_node_facts{% if image_command_tool == 'crictl' %}_crictl{% else %}{% endif %}.yml"
|
||||||
when:
|
when:
|
||||||
- not (download_always_pull or skip_downloads) | default(false)
|
- not (download_always_pull or skip_downloads) | default(false)
|
||||||
block:
|
|
||||||
- name: Download | Generate a list of information about the images on a node
|
|
||||||
command: "{{ image_info_command }}"
|
|
||||||
register: node_images_raw
|
|
||||||
changed_when: false
|
|
||||||
check_mode: false
|
|
||||||
- name: Download | Set node_images (crictl)
|
|
||||||
set_fact:
|
|
||||||
node_images: >-
|
|
||||||
{{
|
|
||||||
(node_images | default([])) +
|
|
||||||
[{'Digest': (item.repoDigests[0] | split('@'))[1], 'Repository': ((item.repoTags[0] | split(':'))[0] | regex_replace('^docker\.io/(library/)?', '')), 'Tag': (item.repoTags[0] | split(':'))[1]}]
|
|
||||||
}}
|
|
||||||
with_items: "{{ (node_images_raw.stdout | from_json).images }}"
|
|
||||||
when:
|
|
||||||
- image_command_tool == 'crictl'
|
|
||||||
- node_images_raw.stdout != ''
|
|
||||||
# In case of nerdctl or docker, the output is already in the expected format
|
|
||||||
# {"Digest":"sha256:847423221ed040798e47df36450edce5581ed642cd087ccb210532764da38b23","Repository":"quay.io/coreos/etcd","Tag":"v3.5.12"}
|
|
||||||
# {"Digest":"sha256:34fc87c4a60c0b3ba3b3608871f4494de8072c02808a4151953068f2d7c87743","Repository":"flannel/flannel","Tag":"latest"}
|
|
||||||
- name: Download | Set node_images (nerdctl, docker)
|
|
||||||
set_fact:
|
|
||||||
node_images: "{{ node_images_raw.stdout_lines | map('from_json') | list }}"
|
|
||||||
when:
|
|
||||||
- image_command_tool in ['nerdctl', 'docker']
|
|
||||||
- when node_images_raw.stdout_lines != ''
|
|
||||||
|
|
||||||
- name: Show node images
|
- name: Show node images
|
||||||
debug:
|
debug:
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# In case of nerdctl or docker, the output is already in the expected format
|
||||||
|
# {"Digest":"sha256:847423221ed040798e47df36450edce5581ed642cd087ccb210532764da38b23","Repository":"quay.io/coreos/etcd","Tag":"v3.5.12"}
|
||||||
|
# {"Digest":"sha256:34fc87c4a60c0b3ba3b3608871f4494de8072c02808a4151953068f2d7c87743","Repository":"flannel/flannel","Tag":"latest"}
|
||||||
|
- name: Download | Set node_images (nerdctl, docker)
|
||||||
|
set_fact:
|
||||||
|
node_images: "{{ node_images_raw.stdout_lines | map('from_json') | list }}"
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
- name: Download | Set node_images (crictl)
|
||||||
|
set_fact:
|
||||||
|
node_images: >-
|
||||||
|
"{{
|
||||||
|
(node_images | default([])) +
|
||||||
|
[{'Digest': (item.repoDigests[0] | split('@'))[1], 'Repository': ((item.repoTags[0] | split(':'))[0] | regex_replace('^docker\.io/(library/)?', '')), 'Tag': (item.repoTags[0] | split(':'))[1]}]
|
||||||
|
}}"
|
||||||
|
with_items: "{{ (node_images_raw.stdout | from_json).images }}"
|
Loading…
Reference in New Issue