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.

30 lines
1.1 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 %}{{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 "{{ '{{' }} (index .RepoTags 0) {{ '}}' }},{{ '{{' }} (index .RepoDigests 0) {{ '}}' }}" | tr '\n' ','
  11. no_log: true
  12. register: docker_images
  13. failed_when: false
  14. changed_when: false
  15. check_mode: no
  16. when: not download_always_pull
  17. - set_fact:
  18. pull_required: >-
  19. {%- if pull_args in docker_images.stdout.split(',') %}false{%- else -%}true{%- endif -%}
  20. when: not download_always_pull
  21. - name: Check the local digest sha256 corresponds to the given image tag
  22. assert:
  23. that: "{{download.repo}}:{{download.tag}} in docker_images.stdout.split(',')"
  24. when: not download_always_pull and not pull_required and pull_by_digest
  25. tags:
  26. - asserts