ansible/test/integration/targets/docker_image/tasks/tests/basic.yml
Felix Fontein 12d26eceb1 docker modules: make sure everything works with older docker-py versions (#55258)
* General test improvements.

* Adjust tests to older docker-py versions.

* docker_swarm_server_info: work around problems with older docker-py versions

* Bump minimal docker-py version for options network_filters and disk_usage.

* More general test improvements.

* Correct usage of docker_image.

* Put files into output directory.

* Speed up test.

* Remove old check.
2019-04-17 13:50:57 -04:00

162 lines
3.8 KiB
YAML

---
####################################################################
## basic ###########################################################
####################################################################
- name: Make sure image is not there
docker_image:
name: "hello-world:latest"
state: absent
force_absent: yes
register: absent_1
- name: Make sure image is not there (idempotency)
docker_image:
name: "hello-world:latest"
state: absent
register: absent_2
- assert:
that:
- absent_2 is not changed
- name: Make sure image is there
docker_image:
name: "hello-world:latest"
state: present
source: pull
register: present_1
- name: Make sure image is there (idempotent)
docker_image:
name: "hello-world:latest"
state: present
source: pull
register: present_2
- assert:
that:
- present_1 is changed
- present_2 is not changed
- name: Make sure tag is not there
docker_image:
name: "hello-world:alias"
state: absent
- name: Tag image with alias
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
register: tag_1
- name: Tag image with alias (idempotent)
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
register: tag_2
- name: Tag image with alias (force, still idempotent)
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
force_tag: yes
register: tag_3
- assert:
that:
- tag_1 is changed
- tag_2 is not changed
- tag_3 is not changed
- name: Cleanup alias tag
docker_image:
name: "hello-world:alias"
state: absent
####################################################################
## interact with test registry #####################################
####################################################################
- name: Make sure image is not there
docker_image:
name: "{{ registry_address }}/test/hello-world:latest"
state: absent
force_absent: yes
- name: Push image to test registry
docker_image:
name: "hello-world:latest"
repository: "{{ registry_address }}/test/hello-world"
push: yes
source: local
register: push_1
- name: Push image to test registry (idempotent)
docker_image:
name: "hello-world:latest"
repository: "{{ registry_address }}/test/hello-world"
push: yes
source: local
register: push_2
- name: Push image to test registry (force, still idempotent)
docker_image:
name: "hello-world:latest"
repository: "{{ registry_address }}/test/hello-world"
push: yes
source: local
force_tag: yes
register: push_3
- assert:
that:
- push_1 is changed
- push_2 is not changed
- push_3 is not changed
- name: Get facts of local image
docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest"
register: facts_1
- name: Make sure image is not there
docker_image:
name: "{{ registry_address }}/test/hello-world:latest"
state: absent
force_absent: yes
- name: Get facts of local image (absent)
docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest"
register: facts_2
- name: Pull image from test registry
docker_image:
name: "{{ registry_address }}/test/hello-world:latest"
state: present
source: pull
register: pull_1
- name: Pull image from test registry (idempotency)
docker_image:
name: "{{ registry_address }}/test/hello-world:latest"
state: present
source: pull
register: pull_2
- name: Get facts of local image (present)
docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest"
register: facts_3
- assert:
that:
- pull_1 is changed
- pull_2 is not changed
- facts_1.images | length == 1
- facts_2.images | length == 0
- facts_3.images | length == 1