ansible/roles/docker/tasks/services/docker_registry.yml

41 lines
1.2 KiB
YAML

# vim: ft=yaml.ansible
---
- name: Create Docker registry volume folders
file:
path: "{{ services.docker_registry.volume_folder }}/{{ volume }}"
state: directory
loop:
- auth
- registry
loop_control:
loop_var: volume
- name: Copy docker registry vhost configuration
copy:
src: vhost/docker_registry
dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.docker_registry.domain }}"
mode: "0644"
- name: Upload Compose file for Docker registry
template:
src: compose-files/docker_registry.yml.j2
dest: "{{ services.docker_registry.volume_folder }}/docker-compose.yml"
- name: Deploy Docker registry
docker_compose:
project_src: "{{ services.docker_registry.volume_folder }}"
pull: true
state: present
- name: Generate htpasswd file
shell: "docker compose exec registry htpasswd -Bbn docker {{ docker_password }} > auth/htpasswd"
args:
chdir: "{{ services.docker_registry.volume_folder }}"
creates: "{{ services.docker_registry.volume_folder }}/auth/htpasswd"
- name: log in to registry
docker_login:
registry: "{{ 'docker.data.coop' if vagrant else services.docker_registry.domain }}"
username: "docker"
password: "{{ docker_password }}"