ansible/test/integration/roles/test_docker/tasks/registry-tests.yml

63 lines
1.7 KiB
YAML
Raw Normal View History

- name: Configure a private docker registry
service:
name: docker-registry
state: started
- name: Get busybox image id
shell: "docker images | grep busybox | awk '{ print $3 }'"
register: image_id
- name: Tag docker image into the local repository
shell: "docker tag {{ image_id.stdout_lines[0] }} localhost:5000/mine"
- name: Push docker image into the local repository
shell: "docker push localhost:5000/mine"
- name: Remove the busybox image from the local docker
shell: "docker rmi -f {{ image_id.stdout_lines[0] }}"
- name: Remove the new image from the local docker
shell: "docker rmi -f localhost:5000/mine"
- name: Get number of images in docker
shell: "docker images |wc -l"
register: docker_output
- name: Check that there are no images in docker
assert:
that:
- "'1' in docker_output.stdout_lines"
- name: Retrieve the image from private docker server
docker:
image: "localhost:5000/mine"
state: present
pull: missing
insecure_registry: True
- name: Run a small script in the new image
docker:
image: "localhost:5000/mine"
state: reloaded
pull: always
command: "nc -l -p 2000 -e xargs -n1 echo hello"
detach: True
insecure_registry: True
- name: Get the docker container id
shell: "docker ps | grep mine | awk '{ print $1 }'"
register: container_id
- name: Get the docker container ip
shell: "docker inspect {{ container_id.stdout_lines[0] }} | grep IPAddress | awk -F '\"' '{ print $4 }'"
register: container_ip
- name: Try to access the server
shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000"
register: docker_output
- name: check that the script ran
assert:
that:
- "'hello world' in docker_output.stdout_lines"