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.

33 lines
1.2 KiB

  1. ---
  2. - set_fact:
  3. pull_by_digest: >-
  4. {%- if download.sha256 is defined and download.sha256 != '' -%}true{%- else -%}false{%- endif -%}
  5. - set_fact:
  6. pull_args: >-
  7. {%- if pull_by_digest|bool %}{{download.repo}}@sha256:{{download.sha256}}{%- else -%}{{download.repo}}:{{download.tag}}{%- endif -%}
  8. - name: Register docker images info
  9. raw: >-
  10. {{ docker_bin_dir }}/docker images -q | xargs {{ docker_bin_dir }}/docker inspect -f "{{ '{{' }} .RepoTags {{ '}}' }},{{ '{{' }} .RepoDigests {{ '}}' }}"
  11. no_log: true
  12. register: docker_images_raw
  13. failed_when: false
  14. changed_when: false
  15. check_mode: no
  16. when: not download_always_pull|bool
  17. - set_fact:
  18. docker_images: "{{docker_images_raw.stdout|regex_replace('\\[|\\]|\\n]','')|regex_replace('\\s',',')}}"
  19. no_log: true
  20. when: not download_always_pull|bool
  21. - set_fact:
  22. pull_required: >-
  23. {%- if pull_args in docker_images.split(',') %}false{%- else -%}true{%- endif -%}
  24. when: not download_always_pull|bool
  25. - name: Check the local digest sha256 corresponds to the given image tag
  26. assert:
  27. that: "{{download.repo}}:{{download.tag}} in docker_images.split(',')"
  28. when: not download_always_pull|bool and not pull_required|bool and pull_by_digest|bool