/
/
/
Ansible role that provisions my storage server.
1---
2# Storage Services - Calibre Stack (Calibre + Calibre-Web)
3
4- name: Create Calibre Stack configuration directory structure
5 file:
6 path: "{{ item }}"
7 state: directory
8 owner: "{{ storage_user }}"
9 group: "{{ storage_group }}"
10 mode: '2775'
11 loop:
12 - "{{ calibre_config_dir }}"
13 - "{{ calibre_server_config_dir }}"
14 - "{{ calibre_web_config_dir }}"
15 - "{{ calibre_library_dir }}"
16
17- name: Generate Calibre Stack environment file
18 template:
19 src: calibre-stack.env.j2
20 dest: "{{ calibre_config_dir }}/.env"
21 owner: "{{ storage_user }}"
22 group: "{{ storage_group }}"
23 mode: '0660'
24 notify: restart calibre-stack
25
26- name: Deploy Calibre Stack Docker Compose file
27 template:
28 src: calibre-stack-compose.yml.j2
29 dest: "{{ calibre_config_dir }}/docker-compose.yml"
30 owner: "{{ storage_user }}"
31 group: "{{ storage_group }}"
32 mode: '0664'
33 notify: restart calibre-stack
34
35- name: Check if Calibre directory exists
36 stat:
37 path: "{{ calibre_config_dir }}"
38 register: calibre_dir_stat
39 changed_when: false
40
41- name: Start Calibre Stack services
42 community.docker.docker_compose_v2:
43 project_src: "{{ calibre_config_dir }}"
44 state: present
45 register: calibre_start_result
46 check_mode: no
47 when: calibre_dir_stat.stat.exists
48
49- name: Wait for Calibre services to initialize
50 pause:
51 seconds: 20
52
53- name: Verify Calibre Stack services are running
54 uri:
55 url: "http://localhost:{{ item.port }}"
56 method: GET
57 status_code: [200, 302]
58 register: calibre_health
59 retries: 10
60 delay: 5
61 until: calibre_health.status in [200, 302]
62 ignore_errors: true
63 loop:
64 - { name: "Calibre Server", port: "{{ calibre_desktop_gui_host_port }}" }
65 - { name: "Calibre-Web", port: "{{ calibre_web_host_port }}" }
66 when: calibre_enabled
67
68- name: Display Calibre Stack deployment summary
69 debug:
70 msg: |
71 Calibre Stack Deployment:
72 - Status: {{ 'Started' if calibre_start_result is changed else 'Already running' }}
73
74 Services:
75 {% if calibre_server_enabled %}
76 - Calibre Server: http://{{ ansible_default_ipv4.address }}:{{ calibre_server_host_port }}
77 Direct library access and management
78 {% endif %}
79 {% if calibre_web_enabled %}
80 - Calibre-Web: http://{{ ansible_default_ipv4.address }}:{{ calibre_web_host_port }}
81 Web-based library browsing and reading
82 {% endif %}
83
84 Directories:
85 - Configuration: {{ calibre_config_dir }}
86 - Library: {{ calibre_library_dir }}
87
88 Next Steps:
89 1. Access Calibre-Web and complete initial setup
90 2. Import existing ebook library if available
91 3. Configure metadata sources and preferences
92 4. Set up user accounts and permissions
93 5. Configure email settings for ebook delivery
94