/
/
/
Ansible role that provisions my storage server.
1---
2# Storage Services Validation and Health Checks
3
4- name: Check Docker daemon status
5 systemd:
6 name: docker
7 state: started
8 tags:
9 - storage
10 - validation
11 - docker
12
13- name: Verify storage network exists
14 community.docker.docker_network_info:
15 name: "{{ storage_docker_network }}"
16 register: network_info
17 tags:
18 - storage
19 - validation
20 - network
21
22- name: Display network status
23 debug:
24 msg: "Storage network {{ storage_docker_network }} is available"
25 when: network_info.exists
26 tags:
27 - storage
28 - validation
29 - network
30
31- name: Collect container status for enabled services
32 command: docker compose ps --format json
33 args:
34 chdir: "{{ item.path }}"
35 register: container_status
36 changed_when: false
37 ignore_errors: true
38 loop:
39 - { name: "Jellyfin", path: "{{ jellyfin_data_dir }}", enabled: "{{ jellyfin_enabled }}" }
40 - { name: "Arr Stack", path: "{{ arr_config_dir }}", enabled: "{{ arr_stack_enabled }}" }
41 - { name: "Calibre Stack", path: "{{ calibre_config_dir }}", enabled: "{{ calibre_enabled }}" }
42 - { name: "Restic Server", path: "{{ restic_backup_config_dir }}", enabled: "{{ restic_backup_server_enabled }}" }
43 when: item.enabled
44 tags:
45 - storage
46 - validation
47 - containers
48
49- name: Verify service health endpoints
50 uri:
51 url: "{{ item.url }}"
52 method: GET
53 status_code: "{{ item.status_code | default(200) }}"
54 validate_certs: no
55 register: service_health
56 changed_when: false
57 ignore_errors: true
58 loop:
59 - { name: "Jellyfin", url: "http://localhost:{{ jellyfin_port }}/health", enabled: "{{ jellyfin_enabled }}" }
60 - { name: "Sonarr", url: "http://localhost:{{ sonarr_port }}", enabled: "{{ sonarr_enabled }}" }
61 - { name: "Radarr", url: "http://localhost:{{ radarr_port }}", enabled: "{{ radarr_enabled }}" }
62 - { name: "Prowlarr", url: "http://localhost:{{ prowlarr_port }}", enabled: "{{ prowlarr_enabled }}" }
63 - { name: "Readarr", url: "http://localhost:{{ readarr_port }}", enabled: "{{ readarr_enabled }}" }
64 - { name: "Jellyseer", url: "http://localhost:{{ jellyseer_port }}", enabled: "{{ jellyseer_enabled }}" }
65 - { name: "Calibre Server", url: "http://localhost:{{ calibre_server_port }}", enabled: "{{ calibre_server_enabled }}" }
66 - { name: "Calibre-Web", url: "http://localhost:{{ calibre_web_port }}", enabled: "{{ calibre_web_enabled }}" }
67 - { name: "Restic Server", url: "http://localhost:{{ restic_backup_port }}", status_code: "[200,401]", enabled: "{{ restic_backup_server_enabled }}" }
68 when: item.enabled
69 tags:
70 - storage
71 - validation
72 - health-check
73
74- name: Verify directory permissions
75 stat:
76 path: "{{ item }}"
77 register: dir_stats
78 loop:
79 - "{{ storage_docker_dir }}"
80 - "{{ storage_base_path }}"
81 - "{{ jellyfin_data_dir }}"
82 - "{{ arr_config_dir }}"
83 - "{{ calibre_config_dir }}"
84 - "{{ restic_backup_config_dir }}"
85 tags:
86 - storage
87 - validation
88 - permissions
89
90- name: Display directory permission status
91 debug:
92 msg: |
93 Directory: {{ item.item }}
94 Owner: {{ item.stat.pw_name }}:{{ item.stat.gr_name }}
95 Permissions: {{ item.stat.mode }}
96 Accessible: {{ item.stat.readable and item.stat.writable }}
97 loop: "{{ dir_stats.results }}"
98 when: item.stat is defined
99 tags:
100 - storage
101 - validation
102 - permissions
103
104- name: Generate storage services health check script
105 template:
106 src: storage-health-check.sh.j2
107 dest: "{{ storage_docker_dir }}/storage-health-check.sh"
108 owner: "{{ storage_user }}"
109 group: "{{ storage_group }}"
110 mode: '0755'
111 tags:
112 - storage
113 - validation
114 - monitoring
115
116- name: Run comprehensive health check
117 command: "{{ storage_docker_dir }}/storage-health-check.sh"
118 register: health_check_result
119 changed_when: false
120 ignore_errors: true
121 tags:
122 - storage
123 - validation
124 - health-check
125
126- name: Display health check results
127 debug:
128 msg: "{{ health_check_result.stdout_lines | default(['Health check script not available']) }}"
129 tags:
130 - storage
131 - validation
132 - health-check
133
134- name: Check for common configuration issues
135 block:
136 - name: Verify VPN configuration if enabled
137 debug:
138 msg: "WARNING: VPN credentials may need configuration in vault"
139 when:
140 - gluetun_enabled
141 - vpn_service_provider == ""
142 tags:
143 - storage
144 - validation
145 - vpn
146
147 - name: Verify backup authentication if enabled
148 debug:
149 msg: "WARNING: Restic authentication credentials need configuration in vault"
150 when:
151 - restic_backup_server_enabled
152 - restic_backup_username == ""
153 tags:
154 - storage
155 - validation
156 - backup
157
158 - name: Check media directory accessibility
159 stat:
160 path: "{{ item }}"
161 register: media_access
162 failed_when: not media_access.stat.exists
163 loop: "{{ media_directories }}"
164 tags:
165 - storage
166 - validation
167 - media
168
169 rescue:
170 - name: Display configuration warnings
171 debug:
172 msg: |
173 Some configuration issues detected:
174 - Check that all required vault variables are configured
175 - Verify storage paths are accessible
176 - Ensure VPN credentials are set if using Gluetun
177 - Confirm backup authentication is configured
178 tags:
179 - storage
180 - validation
181 - warnings