f4bf952f34
This ensures that we cleanup images that are superceded and no longer necessary. We do this to avoid filling the disk with docker images. Note that we use the -f flag to avoid being prompted by docker image prune for confirmation. Change-Id: I8eb5bb97d8c66755e695498707220c9e6e7b2de0
62 lines
1.6 KiB
YAML
62 lines
1.6 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
|
|
- etc
|
|
- 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: Write registry config
|
|
template:
|
|
src: config.yml.j2
|
|
dest: /var/registry/etc/config.yml
|
|
- 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: Run docker prune to cleanup unneeded images
|
|
shell:
|
|
cmd: docker image prune -f
|
|
|
|
- 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"
|