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,17 +9,17 @@
|
||||
####################################################################
|
||||
|
||||
- name: Create random nginx frontend name
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
daemon_nginx_frontend: '{{ "ansible-docker-test-daemon-frontend-%0x" % ((2**32) | random) }}'
|
||||
|
||||
- block:
|
||||
- name: Create volume for config files
|
||||
docker_volume:
|
||||
community.docker.docker_volume:
|
||||
name: '{{ daemon_nginx_frontend }}'
|
||||
state: present
|
||||
|
||||
- name: Create container for nginx frontend for daemon
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
state: stopped
|
||||
name: '{{ daemon_nginx_frontend }}'
|
||||
image: "{{ docker_test_image_registry_nginx }}"
|
||||
@@ -35,7 +35,7 @@
|
||||
register: nginx_container
|
||||
|
||||
- name: Copy config files
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ remote_tmp_dir }}/{{ item }}"
|
||||
mode: "0644"
|
||||
@@ -43,7 +43,7 @@
|
||||
- nginx.conf
|
||||
|
||||
- name: Copy static files into volume
|
||||
docker_container_copy_into:
|
||||
community.docker.docker_container_copy_into:
|
||||
container: '{{ daemon_nginx_frontend }}'
|
||||
path: '{{ remote_tmp_dir }}/{{ item }}'
|
||||
container_path: '/etc/nginx/{{ item }}'
|
||||
@@ -110,7 +110,7 @@
|
||||
provider: ownca
|
||||
|
||||
- name: Copy dynamic files into volume
|
||||
docker_container_copy_into:
|
||||
community.docker.docker_container_copy_into:
|
||||
container: '{{ daemon_nginx_frontend }}'
|
||||
path: '{{ remote_tmp_dir }}/{{ item }}'
|
||||
container_path: '/etc/nginx/{{ item }}'
|
||||
@@ -122,22 +122,22 @@
|
||||
- cert.key
|
||||
|
||||
- name: Start nginx frontend for daemon
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
name: '{{ daemon_nginx_frontend }}'
|
||||
state: started
|
||||
register: nginx_container
|
||||
|
||||
- name: Output nginx container network settings
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: nginx_container.container.NetworkSettings
|
||||
|
||||
- name: Get proxied daemon URLs
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
docker_daemon_frontend_https: "https://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
|
||||
docker_daemon_frontend_http: "http://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:6000"
|
||||
|
||||
- name: Wait for registry frontend
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: '{{ docker_daemon_frontend_http }}/version'
|
||||
register: result
|
||||
until: result is success
|
||||
@@ -145,29 +145,29 @@
|
||||
delay: 1
|
||||
|
||||
- name: Get docker daemon information directly
|
||||
docker_host_info:
|
||||
community.docker.docker_host_info:
|
||||
register: output_direct
|
||||
|
||||
- name: Show direct host info
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: output_direct.host_info | sanitize_host_info
|
||||
|
||||
- name: Get docker daemon information via HTTP
|
||||
docker_host_info:
|
||||
community.docker.docker_host_info:
|
||||
docker_host: '{{ docker_daemon_frontend_http }}'
|
||||
register: output_http
|
||||
|
||||
- name: Show HTTP host info
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: output_http.host_info | sanitize_host_info
|
||||
|
||||
- name: Check that information matches
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (output_direct.host_info | sanitize_host_info) == (output_http.host_info | sanitize_host_info)
|
||||
|
||||
- name: Get docker daemon information via HTTPS
|
||||
docker_host_info:
|
||||
community.docker.docker_host_info:
|
||||
docker_host: '{{ docker_daemon_frontend_https }}'
|
||||
tls_hostname: daemon-tls.ansible.com
|
||||
ca_cert: '{{ remote_tmp_dir }}/ca.pem'
|
||||
@@ -176,32 +176,32 @@
|
||||
register: output_https
|
||||
|
||||
- name: Show HTTPS host info
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: output_https.host_info | sanitize_host_info
|
||||
|
||||
- name: Check that information matches
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (output_direct.host_info | sanitize_host_info) == (output_https.host_info | sanitize_host_info)
|
||||
|
||||
always:
|
||||
- name: Obtain logs from the nginx frontend
|
||||
command: docker logs {{ daemon_nginx_frontend }}
|
||||
ansible.builtin.command: docker logs {{ daemon_nginx_frontend }}
|
||||
register: output
|
||||
ignore_errors: true
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
var: output.stdout_lines
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove container
|
||||
docker_container:
|
||||
community.docker.docker_container:
|
||||
state: absent
|
||||
name: '{{ daemon_nginx_frontend }}'
|
||||
force_kill: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove volume
|
||||
docker_volume:
|
||||
community.docker.docker_volume:
|
||||
name: '{{ daemon_nginx_frontend }}'
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
Reference in New Issue
Block a user