You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

  1. ---
  2. - name: Set if containers should be pulled by digest
  3. set_fact:
  4. pull_by_digest: >-
  5. {%- if download.sha256 is defined and download.sha256 -%}true{%- else -%}false{%- endif -%}
  6. - name: Set pull_args
  7. set_fact:
  8. pull_args: >-
  9. {%- if pull_by_digest %}{{ download.repo }}@sha256:{{ download.sha256 }}{%- else -%}{{ download.repo }}:{{ download.tag }}{%- endif -%}
  10. - name: Set image pull command for containerd
  11. set_fact:
  12. image_pull_command: "{{ bin_dir }}/crictl pull"
  13. when: container_manager in ['crio' ,'containerd']
  14. - name: Register docker images info
  15. shell: "{{ image_info_command }}"
  16. no_log: true
  17. register: docker_images
  18. failed_when: false
  19. changed_when: false
  20. check_mode: no
  21. when:
  22. - not download_always_pull
  23. - group_names | intersect(download.groups) | length
  24. - name: Set if pull is required per container
  25. set_fact:
  26. pull_required: >-
  27. {%- if pull_args in docker_images.stdout.split(',') %}false{%- else -%}true{%- endif -%}
  28. when:
  29. - not download_always_pull
  30. - group_names | intersect(download.groups) | length
  31. - name: Does any host require container pull?
  32. vars:
  33. hosts_pull_required: "{{ hostvars.values() | map(attribute='pull_required') | select('defined') | list }}"
  34. set_fact:
  35. any_pull_required: "{{ True in hosts_pull_required }}"
  36. run_once: true
  37. changed_when: false
  38. when: not download_always_pull
  39. - name: Check the local digest sha256 corresponds to the given image tag
  40. assert:
  41. that: "{{ download.repo }}:{{ download.tag }} in docker_images.stdout.split(',')"
  42. when:
  43. - group_names | intersect(download.groups) | length
  44. - not download_always_pull
  45. - not pull_required
  46. - pull_by_digest
  47. tags:
  48. - asserts