ansible/playbooks/manual/oci-registry-prune.yml
2020-06-10 17:55:58 -04:00

48 lines
1.6 KiB
YAML

# This playbook search for old OCI images on the candidate registries
# and deletes them.
# Once the images tags are deleted the garbage collection is run on the
# registry hosts.
- name: Prune 30 days old OCI images from candidate-registry
hosts: oci-candidate-registry01.iad2.fedoraproject.org:oci-candidate-registry01.stg.iad2.fedoraproject.org
gather_facts: false
user: root
vars:
- ansible_python_interpreter: "/usr/bin/python3"
vars_files:
- "/srv/private/ansible/vars.yml"
tasks:
- name: Find and Delete 30 days old OCI images
delete_old_oci_images:
days: 30
username: "{{candidate_registry_osbs_prod_username}}"
password: "{{candidate_registry_osbs_prod_password}}"
delegate_to: compose-x86-01.iad2.fedoraproject.org
when: env == "production"
register: prod_output
- debug: var=prod_output.stdout_lines
- name: Run registry garbage collection to reclaim disk space
command: "registry garbage-collect /etc/docker-distribution/registry/config.yml"
when: env == "production"
- name: Find and Delete 30 days old OCI images (stg)
delete_old_oci_images:
registry: "https://candidate-registry.stg.fedoraproject.org"
days: 30
username: "{{candidate_registry_osbs_stg_username}}"
password: "{{candidate_registry_osbs_stg_password}}"
delegate_to: compose-x86-01.iad2.fedoraproject.org
when: env == "staging"
register: stg_output
- debug: var=stg_output.stdout_lines
- name: Run registry garbage collection to reclaim disk space (stg)
command: "registry garbage-collect /etc/docker-distribution/registry/config.yml"
when: env == "staging"