/
/
/
Ansible role that provisions my storage server.
1---
2# Storage Services - Pull latest images and recreate containers
3#
4# Usage via update-services.yml:
5# All storage services: ansible-playbook update-services.yml --limit storage_servers
6# Single service: ansible-playbook update-services.yml --limit storage_servers --tags jellyfin
7# Multiple services: ansible-playbook update-services.yml --limit storage_servers --tags "jellyfin,arr-stack"
8# Tags: jellyfin, arr-stack, calibre, restic, nextcloud, gdu
9
10- name: Update Jellyfin
11 when: jellyfin_enabled
12 tags: [jellyfin, media]
13 block:
14 - name: "Jellyfin - Pull latest images"
15 community.docker.docker_compose_v2:
16 project_src: "{{ jellyfin_data_dir }}"
17 state: present
18 pull: always
19 recreate: auto
20 register: jellyfin_update
21
22 - name: "Jellyfin - Report update status"
23 debug:
24 msg: "Jellyfin: {{ 'updated and recreated' if jellyfin_update.changed else 'already up to date' }}"
25
26- name: Update Arr Stack
27 when: arr_stack_enabled
28 tags: [arr-stack, automation]
29 block:
30 - name: "Arr Stack - Build LazyLibrarian image if custom build"
31 community.docker.docker_compose_v2:
32 project_src: "{{ arr_config_dir }}"
33 services: ["lazylibrarian"]
34 state: present
35 build: always
36 recreate: auto
37 when: lazylibrarian_enabled and lazylibrarian_custom_build | default(false)
38 register: lazylibrarian_build
39
40 - name: "Arr Stack - Pull latest images and recreate"
41 community.docker.docker_compose_v2:
42 project_src: "{{ arr_config_dir }}"
43 state: present
44 pull: always
45 recreate: auto
46 register: arr_update
47
48 - name: "Arr Stack - Report update status"
49 debug:
50 msg: "Arr Stack: {{ 'updated and recreated' if arr_update.changed else 'already up to date' }}"
51
52- name: Update gdu
53 when: gdu_enabled
54 tags: [gdu, monitoring]
55 block:
56 # gdu is pinned in vars/main.yml, so this only changes anything after the
57 # pin is bumped. A recreate starts a fresh scan of the array.
58 - name: "gdu - Pull pinned image and recreate"
59 community.docker.docker_compose_v2:
60 project_src: "{{ gdu_config_dir }}"
61 state: present
62 pull: always
63 recreate: auto
64 register: gdu_update
65
66 - name: "gdu - Report update status"
67 debug:
68 msg: "gdu: {{ 'updated and recreated' if gdu_update.changed else 'already up to date' }}"
69
70- name: Update Calibre Stack
71 when: calibre_enabled
72 tags: [calibre, books]
73 block:
74 - name: "Calibre Stack - Pull latest images and recreate"
75 community.docker.docker_compose_v2:
76 project_src: "{{ calibre_config_dir }}"
77 state: present
78 pull: always
79 recreate: auto
80 register: calibre_update
81
82 - name: "Calibre Stack - Report update status"
83 debug:
84 msg: "Calibre Stack: {{ 'updated and recreated' if calibre_update.changed else 'already up to date' }}"
85
86- name: Update Restic Server
87 when: restic_backup_server_enabled
88 tags: [restic, backup]
89 block:
90 - name: "Restic Server - Pull latest image and recreate"
91 community.docker.docker_compose_v2:
92 project_src: "{{ restic_backup_config_dir }}"
93 state: present
94 pull: always
95 recreate: auto
96 register: restic_update
97
98 - name: "Restic Server - Report update status"
99 debug:
100 msg: "Restic Server: {{ 'updated and recreated' if restic_update.changed else 'already up to date' }}"
101
102- name: Update Nextcloud Stack
103 when: nextcloud_enabled
104 tags: [nextcloud, cloud]
105 block:
106 - name: "Nextcloud - Pull latest images and recreate"
107 community.docker.docker_compose_v2:
108 project_src: "{{ nextcloud_config_dir }}"
109 state: present
110 pull: always
111 recreate: auto
112 register: nextcloud_update
113
114 - name: "Nextcloud - Report update status"
115 debug:
116 msg: "Nextcloud Stack: {{ 'updated and recreated' if nextcloud_update.changed else 'already up to date' }}"
117
118- name: Prune unused Docker images
119 tags: [cleanup, prune]
120 community.docker.docker_prune:
121 images: true
122 images_filters:
123 dangling: "true"
124 register: prune_result
125
126- name: Report cleanup
127 tags: [cleanup, prune]
128 debug:
129 msg: "Pruned {{ prune_result.images | default([]) | length }} dangling image(s), reclaimed {{ prune_result.images_space_reclaimed | default(0) | human_readable }}"
130 when: prune_result.images | default([]) | length > 0
131