Ansible role to deploy a container registry
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-role-container-regi.../handlers/main.yml

56 lines
1.4 KiB

---
- name: restart docker
command: /bin/true
notify:
- Docker | reload systemd
- Docker | reload docker
- Docker | pause while Docker restarts
- Docker | wait for docker
listen: "restart docker service"
- name: restart docker-distribution
command: /bin/true
notify:
- Docker | reload systemd
- Docker | reload docker-distribution
- Docker | wait for registry
listen: "restart docker-distribution service"
- name: Docker | reload systemd
systemd:
daemon_reload: yes
when: ansible_service_mgr == 'systemd'
- name: Docker | reload docker
service:
name: docker
state: restarted
- name: Docker | pause while Docker restarts
pause:
seconds: 10
prompt: "Waiting for docker restart"
- name: Docker | wait for docker
command: /usr/bin/docker images
register: docker_ready
retries: 10
delay: 5
until: docker_ready.rc == 0
- name: Docker | reload docker-distribution
service:
name: docker-distribution
state: restarted
# NOTE(bogdando): import caveates https://github.com/ansible/ansible/issues/42621
- name: Docker | wait for registry
uri:
# Just checking API version should be fine
# https://docs.docker.com/registry/spec/api/#api-version-check
url: "http://{{ container_registry_host }}:{{ container_registry_port }}/v2/"
return_content: yes
register: registry_status
retries: 10
delay: 5
until: "registry_status.status|int == 200 and 'OK' in registry_status.msg"