/
/
/
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
9- name: Update Jellyfin
10 when: jellyfin_enabled
11 tags: [jellyfin, media]
12 block:
13 - name: "Jellyfin - Pull latest images"
14 community.docker.docker_compose_v2:
15 project_src: "{{ jellyfin_data_dir }}"
16 state: present
17 pull: always
18 recreate: auto
19 register: jellyfin_update
20
21 - name: "Jellyfin - Report update status"
22 debug:
23 msg: "Jellyfin: {{ 'updated and recreated' if jellyfin_update.changed else 'already up to date' }}"
24
25- name: Update Arr Stack
26 when: arr_stack_enabled
27 tags: [arr-stack, automation]
28 block:
29 - name: "Arr Stack - Build LazyLibrarian image if custom build"
30 community.docker.docker_compose_v2:
31 project_src: "{{ arr_config_dir }}"
32 services: ["lazylibrarian"]
33 state: present
34 build: always
35 recreate: auto
36 when: lazylibrarian_enabled and lazylibrarian_custom_build | default(false)
37 register: lazylibrarian_build
38
39 - name: "Arr Stack - Pull latest images and recreate"
40 community.docker.docker_compose_v2:
41 project_src: "{{ arr_config_dir }}"
42 state: present
43 pull: always
44 recreate: auto
45 register: arr_update
46
47 - name: "Arr Stack - Report update status"
48 debug:
49 msg: "Arr Stack: {{ 'updated and recreated' if arr_update.changed else 'already up to date' }}"
50
51- name: Update Calibre Stack
52 when: calibre_enabled
53 tags: [calibre, books]
54 block:
55 - name: "Calibre Stack - Pull latest images and recreate"
56 community.docker.docker_compose_v2:
57 project_src: "{{ calibre_config_dir }}"
58 state: present
59 pull: always
60 recreate: auto
61 register: calibre_update
62
63 - name: "Calibre Stack - Report update status"
64 debug:
65 msg: "Calibre Stack: {{ 'updated and recreated' if calibre_update.changed else 'already up to date' }}"
66
67- name: Update Restic Server
68 when: restic_backup_server_enabled
69 tags: [restic, backup]
70 block:
71 - name: "Restic Server - Pull latest image and recreate"
72 community.docker.docker_compose_v2:
73 project_src: "{{ restic_backup_config_dir }}"
74 state: present
75 pull: always
76 recreate: auto
77 register: restic_update
78
79 - name: "Restic Server - Report update status"
80 debug:
81 msg: "Restic Server: {{ 'updated and recreated' if restic_update.changed else 'already up to date' }}"
82
83- name: Prune unused Docker images
84 tags: [cleanup, prune]
85 community.docker.docker_prune:
86 images: true
87 images_filters:
88 dangling: "true"
89 register: prune_result
90
91- name: Report cleanup
92 tags: [cleanup, prune]
93 debug:
94 msg: "Pruned {{ prune_result.images | default([]) | length }} dangling image(s), reclaimed {{ prune_result.images_space_reclaimed | default(0) | human_readable }}"
95 when: prune_result.images | default([]) | length > 0
96