/
/
/
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: ['validation', 'docker']
9
10- name: Verify storage network exists
11 community.docker.docker_network_info:
12 name: "{{ storage_docker_network }}"
13 register: network_info
14 tags: ['validation', 'network']
15
16- name: Display network status
17 debug:
18 msg: "Storage network {{ storage_docker_network }} is available"
19 when: network_info.exists
20 tags: ['validation', 'network']
21
22- name: Collect container status for enabled services
23 command: docker compose ps --format json
24 args:
25 chdir: "{{ item.path }}"
26 register: container_status
27 changed_when: false
28 ignore_errors: true
29 loop:
30 - { name: "Jellyfin", path: "{{ jellyfin_data_dir }}", enabled: "{{ jellyfin_enabled }}" }
31 - { name: "Arr Stack", path: "{{ arr_config_dir }}", enabled: "{{ arr_stack_enabled }}" }
32 - { name: "Calibre Stack", path: "{{ calibre_config_dir }}", enabled: "{{ calibre_enabled }}" }
33 - { name: "Restic Server", path: "{{ restic_backup_config_dir }}", enabled: "{{ restic_backup_server_enabled }}" }
34 when: item.enabled
35 tags: ['validation', 'containers']
36
37- name: Verify directory permissions
38 stat:
39 path: "{{ item }}"
40 register: dir_stats
41 loop:
42 - "{{ storage_docker_dir }}"
43 - "{{ storage_base_path }}"
44 tags: ['validation', 'permissions']
45
46- name: Display directory permission status
47 debug:
48 msg: |
49 Directory: {{ item.item }}
50 Owner: {{ item.stat.pw_name }}:{{ item.stat.gr_name }}
51 Permissions: {{ item.stat.mode }}
52 Accessible: {{ item.stat.readable and item.stat.writable }}
53 loop: "{{ dir_stats.results }}"
54 when: item.stat is defined
55 tags: ['validation', 'permissions']
56
57- name: Generate storage services health check script
58 template:
59 src: storage-health-check.sh.j2
60 dest: "{{ storage_docker_dir }}/storage-health-check.sh"
61 owner: "{{ storage_user }}"
62 group: "{{ storage_group }}"
63 mode: '0755'
64 tags: ['validation', 'monitoring']
65
66- name: Run comprehensive health check
67 command: "{{ storage_docker_dir }}/storage-health-check.sh"
68 register: health_check_result
69 changed_when: false
70 ignore_errors: true
71 tags: ['validation', 'health-check']
72
73- name: Display health check results
74 debug:
75 msg: "{{ health_check_result.stdout_lines | default(['Health check script not available']) }}"
76 tags: ['validation', 'health-check']
77
78- name: Check for common configuration issues
79 block:
80 - name: Verify VPN configuration if enabled
81 debug:
82 msg: "WARNING: VPN credentials may need configuration in vault"
83 when:
84 - gluetun_enabled
85 - vpn_service_provider == ""
86 tags: ['validation', 'vpn']
87
88 - name: Verify backup authentication if enabled
89 debug:
90 msg: "WARNING: Restic authentication credentials need configuration in vault"
91 when:
92 - restic_backup_server_enabled
93 - restic_backup_username == ""
94 tags: ['validation', 'backup']
95
96 - name: Check media directory accessibility
97 stat:
98 path: "{{ item }}"
99 register: media_access
100 failed_when: not media_access.stat.exists
101 loop: "{{ media_directories }}"
102 tags: ['validation', 'media']
103
104 rescue:
105 - name: Display configuration warnings
106 debug:
107 msg: |
108 Some configuration issues detected:
109 - Check that all required vault variables are configured
110 - Verify storage paths are accessible
111 - Ensure VPN credentials are set if using Gluetun
112 - Confirm backup authentication is configured
113 tags: ['validation', 'warnings']