671250095d
This installs a daily cron job for garbage collecting the docker registry. Note that we need to orphan blobs by deleting their tags for this to result in any cleaned up blobs. This will be done in a separate change. Change-Id: I85c87ee3b3a375e0141ef9b15a0b9e56c0938bd8
54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
- name: Synchronize docker-compose directory
|
|
synchronize:
|
|
src: registry-docker/
|
|
dest: /etc/registry-docker/
|
|
- name: Ensure registry volume directories exists
|
|
file:
|
|
state: directory
|
|
path: "/var/registry/{{ item }}"
|
|
loop:
|
|
- data
|
|
- certs
|
|
- auth
|
|
- name: Install passlib
|
|
package:
|
|
name:
|
|
- python3-passlib
|
|
- python3-bcrypt
|
|
state: present
|
|
- name: Write htpassword file
|
|
htpasswd:
|
|
create: true
|
|
crypt_scheme: bcrypt
|
|
path: /var/registry/auth/htpasswd
|
|
name: "{{ registry_user }}"
|
|
password: "{{ registry_password }}"
|
|
- name: Write TLS private key
|
|
copy:
|
|
content: "{{ registry_tls_key }}"
|
|
dest: /var/registry/certs/domain.key
|
|
- name: Write TLS certificate
|
|
copy:
|
|
content: "{{ registry_tls_cert }}{{ registry_tls_chain | default('') }}"
|
|
dest: /var/registry/certs/domain.crt
|
|
- name: Install docker-compose
|
|
package:
|
|
name:
|
|
- docker-compose
|
|
state: present
|
|
- name: Run docker-compose pull
|
|
shell:
|
|
cmd: docker-compose pull
|
|
chdir: /etc/registry-docker/
|
|
- name: Run docker-compose up
|
|
shell:
|
|
cmd: docker-compose up -d
|
|
chdir: /etc/registry-docker/
|
|
|
|
- name: Install cron to garbage collect the registry daily
|
|
cron:
|
|
name: "docker registry garbage-collect"
|
|
minute: "0"
|
|
hour: "0"
|
|
job: "/usr/bin/docker exec registrydocker_registry_1 registry garbage-collect /etc/docker/registry/config.yml > /dev/null"
|