1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add tests using a docker private registry

This commit is contained in:
Toshio Kuratomi 2015-03-17 14:40:10 -07:00
parent fe6a2d644d
commit 2cfeec3683
2 changed files with 69 additions and 2 deletions

View file

@ -14,5 +14,10 @@
# Add other distributions as the proper packages become available
when: ansible_distribution in ['Fedora']
- include: docker-tests.yml
when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_lsb.major_release|int == 6
#- include: docker-tests.yml
# when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_lsb.major_release|int == 6
- include: registry-tests.yml
# Add other distributions as the proper packages become available
when: ansible_distribution in ['Fedora']

View file

@ -0,0 +1,62 @@
- 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"