Fix docker CI. (#1494)

Backport of ansible-collections/community.docker#50 to stable-1.
This commit is contained in:
Felix Fontein 2020-12-15 20:20:43 +01:00 committed by GitHub
parent 777a741d4d
commit 6d4760eb20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 54 additions and 58 deletions

View file

@ -11,7 +11,7 @@
name: "{{ image }}" name: "{{ image }}"
source: pull source: pull
loop: loop:
- "{{ docker_test_image_hello_world }}:latest" - "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}" - "{{ docker_test_image_alpine }}"
loop_control: loop_control:
loop_var: image loop_var: image
@ -19,7 +19,7 @@
- name: Get image ID of {{ docker_test_image_hello_world }} and {{ docker_test_image_alpine }} images - name: Get image ID of {{ docker_test_image_hello_world }} and {{ docker_test_image_alpine }} images
docker_image_info: docker_image_info:
name: name:
- "{{ docker_test_image_hello_world }}:latest" - "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}" - "{{ docker_test_image_alpine }}"
register: image_info register: image_info
@ -103,25 +103,25 @@
- create_6.container.Image == image_info.images[1].Id - create_6.container.Image == image_info.images[1].Id
- create_6.container.Id == create_4.container.Id # make sure container wasn't recreated - create_6.container.Id == create_4.container.Id # make sure container wasn't recreated
- name: Create container with {{ docker_test_image_hello_world }} image via old digest - name: Create container with {{ docker_test_image_digest_base }} image via old digest
docker_container: docker_container:
image: "{{ docker_test_image_hello_world }}@sha256:{{ docker_test_image_hello_world_digest_v1 }}" image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v1 }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes
register: digest_1 register: digest_1
- name: Create container with {{ docker_test_image_hello_world }} image via old digest (idempotent) - name: Create container with {{ docker_test_image_digest_base }} image via old digest (idempotent)
docker_container: docker_container:
image: "{{ docker_test_image_hello_world }}@sha256:{{ docker_test_image_hello_world_digest_v1 }}" image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v1 }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes
register: digest_2 register: digest_2
- name: Update container with {{ docker_test_image_hello_world }} image via new digest - name: Update container with {{ docker_test_image_digest_base }} image via new digest
docker_container: docker_container:
image: "{{ docker_test_image_hello_world }}@sha256:{{ docker_test_image_hello_world_digest_v2 }}" image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v2 }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes

View file

@ -587,12 +587,6 @@
# of hello-world. We don't know why this happens, but it happens # of hello-world. We don't know why this happens, but it happens
# often enough to be annoying. That's why we disable this for now, # often enough to be annoying. That's why we disable this for now,
# and simply test that 'Output' is contained in the result. # and simply test that 'Output' is contained in the result.
# NOTE {{ docker_test_image_hello_world }} is no longer necessarily the
# hello-world image, so we potentially have a different output
# anyway. If someone wants to revive this test, it's probably best
# to keep {{ docker_test_image_hello_world }} as some image that
# has 'echo' and execute 'echo "Hello from Docker!"' or something
# like that.
- "'Output' in detach_no_cleanup.container" - "'Output' in detach_no_cleanup.container"
# - "'Hello from Docker!' in detach_no_cleanup.container.Output" # - "'Hello from Docker!' in detach_no_cleanup.container.Output"
- detach_no_cleanup_cleanup is changed - detach_no_cleanup_cleanup is changed

View file

@ -5,14 +5,14 @@
- name: Make sure image is not there - name: Make sure image is not there
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
state: absent state: absent
force_absent: yes force_absent: yes
register: absent_1 register: absent_1
- name: Make sure image is not there (idempotency) - name: Make sure image is not there (idempotency)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
state: absent state: absent
register: absent_2 register: absent_2
@ -22,14 +22,14 @@
- name: Make sure image is there - name: Make sure image is there
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
state: present state: present
source: pull source: pull
register: present_1 register: present_1
- name: Make sure image is there (idempotent) - name: Make sure image is there (idempotent)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
state: present state: present
source: pull source: pull
register: present_2 register: present_2
@ -41,28 +41,28 @@
- name: Make sure tag is not there - name: Make sure tag is not there
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:alias" name: "{{ docker_test_image_hello_world_base }}:alias"
state: absent state: absent
- name: Tag image with alias - name: Tag image with alias
docker_image: docker_image:
source: local source: local
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ docker_test_image_hello_world }}:alias" repository: "{{ docker_test_image_hello_world_base }}:alias"
register: tag_1 register: tag_1
- name: Tag image with alias (idempotent) - name: Tag image with alias (idempotent)
docker_image: docker_image:
source: local source: local
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ docker_test_image_hello_world }}:alias" repository: "{{ docker_test_image_hello_world_base }}:alias"
register: tag_2 register: tag_2
- name: Tag image with alias (force, still idempotent) - name: Tag image with alias (force, still idempotent)
docker_image: docker_image:
source: local source: local
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ docker_test_image_hello_world }}:alias" repository: "{{ docker_test_image_hello_world_base }}:alias"
force_tag: yes force_tag: yes
register: tag_3 register: tag_3
@ -74,5 +74,5 @@
- name: Cleanup alias tag - name: Cleanup alias tag
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:alias" name: "{{ docker_test_image_hello_world_base }}:alias"
state: absent state: absent

View file

@ -22,31 +22,31 @@
state: absent state: absent
force_absent: yes force_absent: yes
- name: Make sure we have {{ docker_test_image_hello_world }}:latest - name: Make sure we have {{ docker_test_image_hello_world }}
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
source: pull source: pull
- name: Push image to test registry - name: Push image to test registry
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ hello_world_image_base }}" repository: "{{ hello_world_image_base }}:latest"
push: yes push: yes
source: local source: local
register: push_1 register: push_1
- name: Push image to test registry (idempotent) - name: Push image to test registry (idempotent)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ hello_world_image_base }}" repository: "{{ hello_world_image_base }}:latest"
push: yes push: yes
source: local source: local
register: push_2 register: push_2
- name: Push image to test registry (force, still idempotent) - name: Push image to test registry (force, still idempotent)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
repository: "{{ hello_world_image_base }}" repository: "{{ hello_world_image_base }}:latest"
push: yes push: yes
source: local source: local
force_tag: yes force_tag: yes

View file

@ -184,27 +184,27 @@
- name: Archive image - name: Archive image
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
archive_path: "{{ output_dir }}/image.tar" archive_path: "{{ output_dir }}/image.tar"
source: pull source: pull
register: archive_image register: archive_image
- name: remove image - name: remove image
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
state: absent state: absent
force_absent: yes force_absent: yes
- name: load image (changed) - name: load image (changed)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
load_path: "{{ output_dir }}/image.tar" load_path: "{{ output_dir }}/image.tar"
source: load source: load
register: load_image register: load_image
- name: load image (idempotency) - name: load image (idempotency)
docker_image: docker_image:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
load_path: "{{ output_dir }}/image.tar" load_path: "{{ output_dir }}/image.tar"
source: load source: load
register: load_image_1 register: load_image_1

View file

@ -25,23 +25,23 @@
source: pull source: pull
state: present state: present
loop: loop:
- "{{ docker_test_image_hello_world }}:latest" - "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}" - "{{ docker_test_image_alpine }}"
- name: Inspect an available image - name: Inspect an available image
docker_image_info: docker_image_info:
name: "{{ docker_test_image_hello_world }}:latest" name: "{{ docker_test_image_hello_world }}"
register: result register: result
- assert: - assert:
that: that:
- "result.images|length == 1" - "result.images|length == 1"
- "(docker_test_image_hello_world ~ ':latest') in result.images[0].RepoTags" - "docker_test_image_hello_world in result.images[0].RepoTags"
- name: Inspect multiple images - name: Inspect multiple images
docker_image_info: docker_image_info:
name: name:
- "{{ docker_test_image_hello_world }}:latest" - "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}" - "{{ docker_test_image_alpine }}"
register: result register: result
@ -50,7 +50,7 @@
- assert: - assert:
that: that:
- "result.images|length == 2" - "result.images|length == 2"
- "(docker_test_image_hello_world ~ ':latest') in result.images[0].RepoTags" - "docker_test_image_hello_world in result.images[0].RepoTags"
- "docker_test_image_alpine in result.images[1].RepoTags" - "docker_test_image_alpine in result.images[1].RepoTags"
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')

View file

@ -1,5 +1,5 @@
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600

View file

@ -2,7 +2,7 @@ stack_compose_base:
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600
stack_compose_overrides: stack_compose_overrides:

View file

@ -1,5 +1,5 @@
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600

View file

@ -2,7 +2,7 @@ stack_compose_base:
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600
stack_compose_overrides: stack_compose_overrides:

View file

@ -74,7 +74,7 @@
that: that:
- 'output.results | type_debug == "list"' - 'output.results | type_debug == "list"'
- 'output.results[0].DesiredState == "Running"' - 'output.results[0].DesiredState == "Running"'
- 'output.results[0].Image == docker_test_image_busybox ~ ":latest"' - 'output.results[0].Image == docker_test_image_busybox'
- 'output.results[0].Name == "test_stack_busybox.1"' - 'output.results[0].Name == "test_stack_busybox.1"'
always: always:

View file

@ -1,5 +1,5 @@
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600

View file

@ -2,7 +2,7 @@ stack_compose_base:
version: '3' version: '3'
services: services:
busybox: busybox:
image: "{{ docker_test_image_busybox }}:latest" image: "{{ docker_test_image_busybox }}"
command: sleep 3600 command: sleep 3600
stack_compose_overrides: stack_compose_overrides:

View file

@ -47,4 +47,4 @@
- name: run a Docker container on the target Docker Machine host to verify that Docker daemon connection settings from the docker-machine inventory plugin work as expected - name: run a Docker container on the target Docker Machine host to verify that Docker daemon connection settings from the docker-machine inventory plugin work as expected
docker_container: docker_container:
name: test name: test
image: hello-world:latest image: hello-world:latest

View file

@ -1,9 +1,11 @@
--- ---
docker_test_image_hello_world_digest_v1: e004c2cc521c95383aebb1fb5893719aa7a8eae2e7a71f316a4410784edb00a9 docker_test_image_digest_v1: e004c2cc521c95383aebb1fb5893719aa7a8eae2e7a71f316a4410784edb00a9
docker_test_image_hello_world_digest_v2: c9249fdf56138f0d929e2080ae98ee9cb2946f71498fc1484288e6a935b5e5bc docker_test_image_digest_v2: ee44b399df993016003bf5466bd3eeb221305e9d0fa831606bc7902d149c775b
docker_test_image_hello_world: quay.io/app-sre/busybox docker_test_image_digest_base: quay.io/ansible/docker-test-containers
docker_test_image_busybox: quay.io/app-sre/busybox docker_test_image_hello_world: quay.io/ansible/docker-test-containers:hello-world
docker_test_image_alpine: quay.io/app-sre/alpine:3.8 docker_test_image_hello_world_base: quay.io/ansible/docker-test-containers
docker_test_image_alpine_different: quay.io/app-sre/alpine:3.7 docker_test_image_busybox: quay.io/ansible/docker-test-containers:busybox
docker_test_image_registry_nginx: nginx:alpine docker_test_image_alpine: quay.io/ansible/docker-test-containers:alpine3.8
docker_test_image_alpine_different: quay.io/ansible/docker-test-containers:alpine3.7
docker_test_image_registry_nginx: quay.io/ansible/docker-test-containers:nginx-alpine
docker_test_image_registry: registry:2.6.1 docker_test_image_registry: registry:2.6.1