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.

32 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. check_mode: no
  15. when: not download_always_pull|bool
  16. - set_fact:
  17. docker_images: "{{docker_images_raw.stdout|regex_replace('\\[|\\]|\\n]','')|regex_replace('\\s',',')}}"
  18. no_log: true
  19. when: not download_always_pull|bool
  20. - set_fact:
  21. pull_required: >-
  22. {%- if pull_args in docker_images.split(',') %}false{%- else -%}true{%- endif -%}
  23. when: not download_always_pull|bool
  24. - name: Check the local digest sha256 corresponds to the given image tag
  25. assert:
  26. that: "{{download.repo}}:{{download.tag}} in docker_images.split(',')"
  27. when: not download_always_pull|bool and not pull_required|bool and pull_by_digest|bool