Clark Boylan c0fd3e0894 Pull and prune docker images together
We noticed that our zuul scheduler was running out of disk and one of
the causes of this is we are pulling all of the wonderful new zuul
images and not pruning them. This happens because we were only pruning
when (re)starting services and we don't do that automatically with Zuul.
Address this by always pruning after pulling even if we don't restart
services. This should be safe because prune will leave the latest tagged
images as well as the running images.

This should keep our disk consumption down.

Change-Id: Ibdd22ac42d86781f1e87c3d11e05fd8f99677167
2020-05-07 12:51:09 -07:00

70 lines
1.5 KiB
YAML

- name: Create Zuul directories
file:
state: directory
path: '{{ item }}'
owner: zuul
group: zuul
loop:
- /var/lib/zuul/git
- name: Set up cron job to pack git refs
cron:
name: pack-git-refs
state: present
job: 'find /var/lib/zuul/git/ -maxdepth 3 -type d -name ".git" -exec git --git-dir="{}" pack-refs --all \;'
minute: '7'
hour: '4'
- name: Install logging config
copy:
src: logging.conf
dest: /etc/zuul/merger-logging.conf
- name: Rotate merger logs
include_role:
name: logrotate
vars:
logrotate_file_name: /var/log/zuul/merger.log
- name: Rotate merger debug logs
include_role:
name: logrotate
vars:
logrotate_file_name: /var/log/zuul/merger-debug.log
- name: Make docker-compose directory
file:
state: directory
path: /etc/zuul-merger
- name: Install docker-compose file
copy:
src: docker-compose.yaml
dest: /etc/zuul-merger/docker-compose.yaml
- name: Run docker-compose pull
shell:
cmd: docker-compose pull
chdir: /etc/zuul-merger
- name: Start containers
include_tasks: start.yaml
when: zuul_merger_start | bool
# We can prune here as it should leave the "latest" tagged images
# as well as the currently running images.
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: zuul-merger
enabled: no
failed_when: false
- name: Remove old init scripts
file:
state: absent
path: /etc/init.d/zuul-merger