aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.ansible/roles/cleanup/tasks/clean_images.yaml
blob: 76704ab50dd523fbaecf846414f596405981d0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
# file: tasks/clean_images.yaml

- name: Clean Docker Images
  block:
  - name: Clean Images - Prefetch Docker Images
    ansible.builtin.cron:
      name: "Prefetch docker image {{ item }}"
      minute: "10"
      hour: "7"
      job: "/usr/bin/docker pull {{ item }}"
    loop:
      "{{ images_to_prefetch_by_arch[ansible_machine] }}"
    tags:
      - prefetch-docker-images

  - name: Clean Images - Remove Dangling Docker Images
    ansible.builtin.cron:
      name: "Remove dangling docker images"
      minute: "10"
      hour: "5"
      weekday: "7"
      job: "/usr/bin/docker rmi $(/usr/bin/docker images --filter 'dangling=true' -q)"
    tags:
      - remove-docker-images-dangling

# TODO: Disabled until all images will be in registry
# - name: Clean Images - Prune Docker Images
#   cron:
#     name: "Prune docker images"
#     minute: "10"
#     hour: "6"
#     weekday: 7
#     job: "/usr/bin/docker image prune --all --force"
#   tags:
#     - prune-docker-images