/
/
/
Ansible role that provisions my storage server.
1---
2# Storage Services - gdu Disk Usage Analyzer (web UI)
3#
4# The compose file is the only config, and docker_compose_v2 already recreates
5# the container when it changes - so there is deliberately no restart handler.
6# A handler would recreate it a second time and throw away a running scan.
7
8- name: Create gdu configuration directory
9 file:
10 path: "{{ gdu_config_dir }}"
11 state: directory
12 owner: "{{ storage_user }}"
13 group: "{{ storage_group }}"
14 mode: '2775'
15
16- name: Deploy gdu Docker Compose file
17 template:
18 src: gdu-compose.yml.j2
19 dest: "{{ gdu_config_dir }}/docker-compose.yml"
20 owner: "{{ storage_user }}"
21 group: "{{ storage_group }}"
22 mode: '0664'
23
24- name: Start gdu service
25 community.docker.docker_compose_v2:
26 project_src: "{{ gdu_config_dir }}"
27 state: present
28 register: gdu_start_result
29 # Skipped rather than forced in check mode: the compose file above is not
30 # written during --check, so there would be nothing real to start.
31 when: not ansible_check_mode
32
33# The UI is served while the scan is still running, so this only waits for
34# the web server - not for the scan to finish.
35- name: Wait for gdu web UI to respond
36 uri:
37 url: "http://localhost:{{ gdu_host_port }}/"
38 method: GET
39 status_code: [200]
40 register: gdu_health
41 until: gdu_health.status == 200
42 retries: 12
43 delay: 5
44 when:
45 - not ansible_check_mode
46 - gdu_start_result is changed
47
48- name: Display gdu deployment summary
49 debug:
50 msg: |
51 gdu Disk Usage Analyzer Deployment:
52 - Status: {{ 'Check mode - not started' if ansible_check_mode else ('Started (scan running)' if gdu_start_result is changed else 'Already running') }}
53 - Web UI: http://{{ gdu_web_hostname }}:{{ gdu_host_port }}
54 - Scanning: {{ gdu_scan_dir }} (read-only, deletion disabled)
55 - Configuration: {{ gdu_config_dir }}
56 - Rescan: cd {{ gdu_config_dir }} && docker compose restart
57