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