e9e3129ffe
This reverts commit 95f0c32a61
.
We add a bit more code on top of the revert to capture output in a log
file (pruning is very verbose) and rotate 30 daily copies of the log
file.
Change-Id: I1778989d676d316537cf135b8e14a255434091b4
100 lines
2.1 KiB
YAML
100 lines
2.1 KiB
YAML
- name: Create registry_service group
|
|
group:
|
|
name: "registry"
|
|
gid: "{{ registry_service_group_id }}"
|
|
system: yes
|
|
|
|
- name: Create registry_service user
|
|
user:
|
|
name: "registry"
|
|
group: "registry"
|
|
uid: "{{ registry_service_user_id }}"
|
|
home: "/var/registry"
|
|
system: yes
|
|
|
|
- name: Make docker-compose dir
|
|
file:
|
|
state: directory
|
|
path: /etc/registry-docker
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Write docker-compose.yaml
|
|
template:
|
|
src: docker-compose.yaml.j2
|
|
dest: /etc/registry-docker/docker-compose.yaml
|
|
owner: root
|
|
group: root
|
|
mode: 644
|
|
|
|
- name: Ensure directory permission
|
|
file:
|
|
state: directory
|
|
path: /var/registry/
|
|
owner: registry
|
|
group: registry
|
|
mode: 0755
|
|
|
|
- name: Ensure registry volume directories exists
|
|
file:
|
|
state: directory
|
|
path: "/var/registry/{{ item }}"
|
|
owner: registry
|
|
group: registry
|
|
loop:
|
|
- certs
|
|
- conf
|
|
- etc
|
|
|
|
- name: Write clouds.yaml
|
|
template:
|
|
src: clouds.yaml.j2
|
|
dest: /var/registry/etc/clouds.yaml
|
|
owner: registry
|
|
group: registry
|
|
|
|
- name: Write registry config
|
|
template:
|
|
src: registry.yaml.j2
|
|
dest: /var/registry/conf/registry.yaml
|
|
owner: registry
|
|
group: registry
|
|
|
|
- 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: Create registry prune log output directory
|
|
file:
|
|
path: /var/log/registry-prune
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
- 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 zuul-registry prune >> /var/log/registry-prune/prune.log 2>&1"
|
|
|
|
- name: Install logrotate rules
|
|
include_role:
|
|
name: logrotate
|
|
vars:
|
|
logrotate_rotate: 30
|
|
logrotate_file_name: '/var/log/registry-prune/prune.log'
|
|
logrotate_frequency: 'daily'
|