Skip to content

Commit

Permalink
check if image command tool is installed before building up a cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Payback159 committed Oct 12, 2024
1 parent d509ef6 commit 36d226a
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions roles/download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,38 @@
- download
- upload

- name: Download | Generate a list of information about the images on a node
command: "{{ image_info_command }}"
register: node_images_raw
- name: Download | Check if image command tool exists
command: "{{ image_command_tool }} --version"
register: image_command_tool_exists
changed_when: false
check_mode: false
when:
- not (download_always_pull or skip_downloads) | default(false)
failed_when: 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"
- name: Download | Check if image command tool exists
stat:
path: "{{ bin_dir }}/{{ image_command_tool }}"
get_attributes: false
get_checksum: false
get_mime: false
register: image_command_tool_exists
changed_when: false

- name: Download | Process and download required files and images
when:
- not (download_always_pull or skip_downloads) | default(false)

- name: Show node images
debug:
msg: "{{ node_images }}"
- image_command_tool_exists.stat.exists
block:
- name: Download | Get image list from node
command: "{{ image_info_command }}"
register: node_images_raw
changed_when: false
check_mode: 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"
- name: Download | Show node images
debug:
msg: "{{ node_images }}"

- name: Download | Download files / images
include_tasks: "{{ include_file }}"
Expand Down Expand Up @@ -68,6 +82,6 @@
)
- (download_run_once and inventory_hostname == download_delegate) or (group_names | intersect(download.groups) | length)

- name: Show downloads
- name: Download | Show downloads
debug:
msg: "{{ downloads }}"

0 comments on commit 36d226a

Please sign in to comment.