mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Don't die when docker CLI doesn't want to work with docker daemon (#366)
* Don't die when docker CLI doesn't want to work with docker daemon. * Allow more 'docker volume ls' failures * More. * Fix more failures. * Forgot ignore_errors. * Another one. * More places. * Try to install newer docker on RHEL8. * Also restrict docker-ce-cli.
This commit is contained in:
parent
49f56697bb
commit
6fca49f445
11 changed files with 251 additions and 181 deletions
|
@ -7,14 +7,20 @@
|
|||
command: "docker logs {{ registry_name }}"
|
||||
register: registry_logs
|
||||
no_log: yes
|
||||
ignore_errors: yes
|
||||
- name: "Printing registry logs"
|
||||
debug: var=registry_logs.stdout_lines
|
||||
debug:
|
||||
var: registry_logs.stdout_lines
|
||||
when: registry_logs is not failed
|
||||
- name: "Get nginx logs"
|
||||
command: "docker logs {{ nginx_name }}"
|
||||
register: nginx_logs
|
||||
no_log: yes
|
||||
ignore_errors: yes
|
||||
- name: "Printing nginx logs"
|
||||
debug: var=nginx_logs.stdout_lines
|
||||
debug:
|
||||
var: nginx_logs.stdout_lines
|
||||
when: nginx_logs is not failed
|
||||
- name: "Make sure all containers are removed"
|
||||
docker_container:
|
||||
name: "{{ item }}"
|
||||
|
|
|
@ -52,47 +52,54 @@
|
|||
loop:
|
||||
- nginx.conf
|
||||
- nginx.htpasswd
|
||||
- name: Create private key for frontend certificate
|
||||
community.crypto.openssl_privatekey:
|
||||
path: '{{ output_dir }}/cert.key'
|
||||
type: ECC
|
||||
curve: secp256r1
|
||||
- name: Create CSR for frontend certificate
|
||||
community.crypto.openssl_csr:
|
||||
path: '{{ output_dir }}/cert.csr'
|
||||
privatekey_path: '{{ output_dir }}/cert.key'
|
||||
subject_alt_name:
|
||||
- DNS:test-registry.ansible.com
|
||||
- name: Create frontend certificate
|
||||
community.crypto.openssl_certificate:
|
||||
path: '{{ output_dir }}/cert.pem'
|
||||
csr_path: '{{ output_dir }}/cert.csr'
|
||||
privatekey_path: '{{ output_dir }}/cert.key'
|
||||
provider: selfsigned
|
||||
- name: Copy dynamic files into volume
|
||||
command: docker cp {{ output_dir }}/{{ item }} {{ nginx_name }}:/etc/nginx/{{ item }}
|
||||
loop:
|
||||
- cert.pem
|
||||
- cert.key
|
||||
- name: Start nginx frontend for registry
|
||||
docker_container:
|
||||
name: '{{ nginx_name }}'
|
||||
state: started
|
||||
register: nginx_container
|
||||
- debug: var=nginx_container.container.NetworkSettings
|
||||
- name: Wait for registry frontend
|
||||
uri:
|
||||
url: https://{{ nginx_container.container.NetworkSettings.IPAddress }}:5000/v2/
|
||||
url_username: testuser
|
||||
url_password: hunter2
|
||||
validate_certs: false
|
||||
register: result
|
||||
until: result is success
|
||||
retries: 5
|
||||
delay: 1
|
||||
- name: Get registry URL
|
||||
set_fact:
|
||||
registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
|
||||
register: can_copy_files
|
||||
ignore_errors: yes
|
||||
- block:
|
||||
- name: Create private key for frontend certificate
|
||||
community.crypto.openssl_privatekey:
|
||||
path: '{{ output_dir }}/cert.key'
|
||||
type: ECC
|
||||
curve: secp256r1
|
||||
- name: Create CSR for frontend certificate
|
||||
community.crypto.openssl_csr:
|
||||
path: '{{ output_dir }}/cert.csr'
|
||||
privatekey_path: '{{ output_dir }}/cert.key'
|
||||
subject_alt_name:
|
||||
- DNS:test-registry.ansible.com
|
||||
- name: Create frontend certificate
|
||||
community.crypto.openssl_certificate:
|
||||
path: '{{ output_dir }}/cert.pem'
|
||||
csr_path: '{{ output_dir }}/cert.csr'
|
||||
privatekey_path: '{{ output_dir }}/cert.key'
|
||||
provider: selfsigned
|
||||
- name: Copy dynamic files into volume
|
||||
command: docker cp {{ output_dir }}/{{ item }} {{ nginx_name }}:/etc/nginx/{{ item }}
|
||||
loop:
|
||||
- cert.pem
|
||||
- cert.key
|
||||
- name: Start nginx frontend for registry
|
||||
docker_container:
|
||||
name: '{{ nginx_name }}'
|
||||
state: started
|
||||
register: nginx_container
|
||||
- debug: var=nginx_container.container.NetworkSettings
|
||||
- name: Wait for registry frontend
|
||||
uri:
|
||||
url: https://{{ nginx_container.container.NetworkSettings.IPAddress }}:5000/v2/
|
||||
url_username: testuser
|
||||
url_password: hunter2
|
||||
validate_certs: false
|
||||
register: result
|
||||
until: result is success
|
||||
retries: 5
|
||||
delay: 1
|
||||
- name: Get registry URL
|
||||
set_fact:
|
||||
registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
|
||||
when: can_copy_files is not failed
|
||||
- set_fact:
|
||||
registry_frontend_address: 'n/a'
|
||||
when: can_copy_files is failed
|
||||
- debug: msg="Registry available under {{ registry_address }}, NGINX frontend available under {{ registry_frontend_address }}"
|
||||
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
|
||||
- fail: msg="Too old docker / docker-py version to run docker_image tests!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue