2018-10-26 00:51:41 +00:00
|
|
|
---
|
|
|
|
- name: Create random name prefix and test registry name
|
|
|
|
set_fact:
|
|
|
|
name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
|
|
|
|
registry_name: "{{ 'ansible-test-registry-%0x' % ((2**32) | random) }}"
|
|
|
|
- name: Create image and container list
|
|
|
|
set_fact:
|
|
|
|
inames: []
|
|
|
|
cnames:
|
|
|
|
- "{{ registry_name }}"
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: "Using name prefix {{ name_prefix }} and test registry name {{ registry_name }}"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Start test registry
|
|
|
|
docker_container:
|
|
|
|
name: "{{ registry_name }}"
|
|
|
|
image: registry:2.6.1
|
|
|
|
ports: 5000
|
|
|
|
|
|
|
|
- name: Get registry URL
|
|
|
|
set_fact:
|
|
|
|
registry_address: "localhost:{{ docker_container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}"
|
|
|
|
|
|
|
|
- debug: msg="Registry available under {{ registry_address }}"
|
|
|
|
|
|
|
|
- include_tasks: run-test.yml
|
|
|
|
with_fileglob:
|
|
|
|
- "tests/*.yml"
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: "Make sure all images are removed"
|
|
|
|
docker_image:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ inames }}"
|
|
|
|
- name: "Get registry logs"
|
|
|
|
command: "docker logs {{ registry_name }}"
|
|
|
|
register: registry_logs
|
|
|
|
- name: "Printing registry logs"
|
|
|
|
debug: var=registry_logs.stdout_lines
|
|
|
|
- name: "Make sure all containers are removed"
|
|
|
|
docker_container:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
2018-11-16 12:37:12 +00:00
|
|
|
force_kill: yes
|
2018-10-26 00:51:41 +00:00
|
|
|
with_items: "{{ cnames }}"
|
|
|
|
|
|
|
|
# Skip for CentOS 6
|
|
|
|
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
|