mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Use FQCNs. (#1180)
This commit is contained in:
@@ -9,5 +9,5 @@
|
||||
####################################################################
|
||||
|
||||
- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
|
||||
include_tasks:
|
||||
ansible.builtin.include_tasks:
|
||||
file: setup.yml
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
# Set up first nginx frontend for registry
|
||||
- name: Start nginx frontend for registry
|
||||
docker_volume:
|
||||
community.docker.docker_volume:
|
||||
name: '{{ docker_registry_container_name_frontend }}'
|
||||
state: present
|
||||
|
||||
- name: Create container for nginx frontend for registry
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
state: stopped
|
||||
name: '{{ docker_registry_container_name_frontend }}'
|
||||
image: "{{ docker_test_image_registry_nginx }}"
|
||||
@@ -30,7 +30,7 @@
|
||||
register: nginx_container
|
||||
|
||||
- name: Copy config files
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ remote_tmp_dir }}/{{ item }}"
|
||||
mode: "0644"
|
||||
@@ -39,7 +39,7 @@
|
||||
- nginx.htpasswd
|
||||
|
||||
- name: Copy static files into volume
|
||||
docker_container_copy_into:
|
||||
community.docker.docker_container_copy_into:
|
||||
container: '{{ docker_registry_container_name_frontend }}'
|
||||
path: '{{ remote_tmp_dir }}/{{ item }}'
|
||||
container_path: '/etc/nginx/{{ item }}'
|
||||
@@ -76,7 +76,7 @@
|
||||
provider: selfsigned
|
||||
|
||||
- name: Copy dynamic files into volume
|
||||
docker_container_copy_into:
|
||||
community.docker.docker_container_copy_into:
|
||||
container: '{{ docker_registry_container_name_frontend }}'
|
||||
path: '{{ remote_tmp_dir }}/{{ item }}'
|
||||
container_path: '/etc/nginx/{{ item }}'
|
||||
@@ -87,17 +87,17 @@
|
||||
- cert.key
|
||||
|
||||
- name: Start nginx frontend for registry
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
name: '{{ docker_registry_container_name_frontend }}'
|
||||
state: started
|
||||
register: nginx_container
|
||||
|
||||
- name: Output nginx container network settings
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: nginx_container.container.NetworkSettings
|
||||
|
||||
- name: Get registry URL
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
# Note that this host/port combination is used by the Docker daemon, that's why `localhost` is appropriate!
|
||||
# This host/port combination cannot be used if the tests are running inside a docker container.
|
||||
docker_registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
|
||||
@@ -105,7 +105,7 @@
|
||||
docker_registry_frontend_address_internal: "{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
|
||||
|
||||
- name: Wait for registry frontend
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: https://{{ docker_registry_frontend_address_internal }}/v2/
|
||||
url_username: testuser
|
||||
url_password: hunter2
|
||||
@@ -115,6 +115,6 @@
|
||||
retries: 5
|
||||
delay: 1
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
docker_registry_frontend_address: 'n/a'
|
||||
when: can_copy_files is failed
|
||||
|
||||
@@ -7,27 +7,27 @@
|
||||
# This must be done **before** docker is set up (see next task), to ensure that the
|
||||
# registry is removed **before** docker itself is removed. This is necessary as the
|
||||
# registry and its frontends run as docker containers.
|
||||
command: 'true'
|
||||
ansible.builtin.command: 'true'
|
||||
notify: Remove test registry
|
||||
|
||||
- name: Setup Docker
|
||||
# Please note that we do setup_docker here and not via meta/main.yml to avoid the problem that
|
||||
# our cleanup is called **after** setup_docker's cleanup has been called!
|
||||
include_role:
|
||||
ansible.builtin.include_role:
|
||||
name: setup_docker
|
||||
|
||||
- name: Figure out current container's network IP
|
||||
include_role:
|
||||
ansible.builtin.include_role:
|
||||
name: setup_docker_current_container_network_ip
|
||||
|
||||
- name: Create random name prefix and test registry name
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
docker_registry_container_name_registry: '{{ ''ansible-docker-test-registry-%0x'' % ((2**32) | random) }}'
|
||||
docker_registry_container_name_nginx: '{{ ''ansible-docker-test-registry-frontend-%0x'' % ((2**32) | random) }}'
|
||||
docker_registry_container_name_nginx2: '{{ ''ansible-docker-test-registry-frontend2-%0x'' % ((2**32) | random) }}'
|
||||
|
||||
- name: Create image and container list
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
docker_registry_setup_inames: []
|
||||
docker_registry_setup_cnames:
|
||||
- '{{ docker_registry_container_name_registry }}'
|
||||
@@ -37,10 +37,10 @@
|
||||
- '{{ docker_registry_container_name_nginx }}'
|
||||
- '{{ docker_registry_container_name_nginx2 }}'
|
||||
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: Using test registry name {{ docker_registry_container_name_registry }} and nginx frontend names {{ docker_registry_container_name_nginx }} and {{ docker_registry_container_name_nginx2 }}
|
||||
|
||||
- fail: msg="Too old docker version to set up docker registry!"
|
||||
- ansible.builtin.fail: msg="Too old docker version to set up docker registry!"
|
||||
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|
||||
|
||||
- when: docker_api_version is version('1.25', '>=')
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
# Set up registry container
|
||||
- name: Start test registry
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
name: '{{ docker_registry_container_name_registry }}'
|
||||
image: "{{ docker_test_image_registry }}"
|
||||
ports: 5000
|
||||
@@ -64,25 +64,25 @@
|
||||
register: registry_container
|
||||
|
||||
- name: Get registry URL
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
registry_address: localhost:{{ registry_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
|
||||
|
||||
# Set up first nginx frontend for registry
|
||||
- include_tasks: setup-frontend.yml
|
||||
- ansible.builtin.include_tasks: setup-frontend.yml
|
||||
vars:
|
||||
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx }}'
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
registry_frontend_address: '{{ docker_registry_frontend_address }}'
|
||||
|
||||
# Set up second nginx frontend for registry
|
||||
- include_tasks: setup-frontend.yml
|
||||
- ansible.builtin.include_tasks: setup-frontend.yml
|
||||
vars:
|
||||
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx2 }}'
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
registry_frontend2_address: '{{ docker_registry_frontend_address }}'
|
||||
|
||||
# Print addresses for registry and frontends
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "Registry available under {{ registry_address }}, NGINX frontends available under {{ registry_frontend_address }} and {{ registry_frontend2_address }}"
|
||||
|
||||
Reference in New Issue
Block a user