Update 4 files
- /group_vars/all.yml - /roles/flibusta/tasks/main.yml - /roles/flibusta/handlers/main.yml - /roles/flibusta/templates/docker-compose.yml.j2
This commit is contained in:
parent
23e09de5e4
commit
89f6833efe
@ -201,13 +201,14 @@ calibre_web_enable_registration: false
|
|||||||
calibre_web_enable_webdav: true
|
calibre_web_enable_webdav: true
|
||||||
calibre_web_enable_opds: true
|
calibre_web_enable_opds: true
|
||||||
|
|
||||||
flibusta_base_dir: "{{ service_config_base }}/flibusta"
|
# ------------ Flibusta ------------
|
||||||
flibusta_books_dir: "/mnt/books/flibusta"
|
flibusta_base_dir: "/mnt/service/flibusta"
|
||||||
flibusta_port: "45135"
|
flibusta_source_archives_dir: "/mnt/books/flibusta"
|
||||||
flibusta_image: "flibusta/fb_tools:full-latest"
|
flibusta_web_port: "45135"
|
||||||
flibusta_webdav_enabled: true
|
flibusta_db_port: "45136"
|
||||||
flibusta_opds_enabled: true
|
flibusta_db_user: "flibusta"
|
||||||
flibusta_calibre_integration: true
|
flibusta_db_password: "flibusta"
|
||||||
|
flibusta_db_name: "flibusta"
|
||||||
|
|
||||||
# ------------ photo (192.168.1.204) ------------
|
# ------------ photo (192.168.1.204) ------------
|
||||||
immich_base_dir: "/mnt/immich"
|
immich_base_dir: "/mnt/immich"
|
||||||
|
|||||||
36
roles/flibusta/handlers/main.yml
Normal file
36
roles/flibusta/handlers/main.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
- name: restart flibusta
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
|
state: present
|
||||||
|
restarted: true
|
||||||
|
|
||||||
|
- name: rebuild flibusta
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
|
state: present
|
||||||
|
build: true
|
||||||
|
restarted: true
|
||||||
|
|
||||||
|
- name: stop flibusta
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
|
state: stopped
|
||||||
|
|
||||||
|
- name: start flibusta
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: update flibusta database
|
||||||
|
shell: |
|
||||||
|
docker exec flibusta_php php /application/tools/import.php --import
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
|
- name: run daily update script
|
||||||
|
shell: |
|
||||||
|
cd {{ flibusta_base_dir }}
|
||||||
|
./update_daily.sh
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
@ -1,28 +1,141 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure Flibusta directories exist
|
- name: Check if Flibusta repository exists
|
||||||
file:
|
stat:
|
||||||
path: "{{ item }}"
|
path: "{{ flibusta_base_dir }}/docker-compose.yml"
|
||||||
state: directory
|
register: flibusta_repo
|
||||||
mode: '0755'
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
loop:
|
|
||||||
- "{{ flibusta_base_dir }}/config"
|
|
||||||
- "{{ flibusta_base_dir }}/data"
|
|
||||||
- "{{ flibusta_books_dir }}"
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Deploy docker-compose.yml for Flibusta
|
- name: Clone Flibusta repository if not exists
|
||||||
|
git:
|
||||||
|
repo: "https://github.com/gibgibik/flibusta.git"
|
||||||
|
dest: "{{ flibusta_base_dir }}"
|
||||||
|
version: main
|
||||||
|
force: no
|
||||||
|
when: not flibusta_repo.stat.exists
|
||||||
|
|
||||||
|
- name: Ensure application directories exist
|
||||||
|
file:
|
||||||
|
path: "{{ flibusta_base_dir }}/{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
loop:
|
||||||
|
- "cache"
|
||||||
|
- "db"
|
||||||
|
- "Flibusta.Net"
|
||||||
|
- "FlibustaSQL"
|
||||||
|
- "blob"
|
||||||
|
|
||||||
|
- name: Copy SQL files from source directory
|
||||||
|
copy:
|
||||||
|
src: "{{ flibusta_source_archives_dir }}/"
|
||||||
|
dest: "{{ flibusta_base_dir }}/FlibustaSQL/"
|
||||||
|
remote_src: true
|
||||||
|
mode: 0644
|
||||||
|
when:
|
||||||
|
- flibusta_source_archives_dir is defined
|
||||||
|
- flibusta_source_archives_dir != ""
|
||||||
|
- lookup('fileglob', flibusta_source_archives_dir + '/*.sql', wantlist=True) | length > 0
|
||||||
|
|
||||||
|
- name: Copy ZIP archives to Flibusta.Net directory
|
||||||
|
copy:
|
||||||
|
src: "{{ flibusta_source_archives_dir }}/"
|
||||||
|
dest: "{{ flibusta_base_dir }}/Flibusta.Net/"
|
||||||
|
remote_src: true
|
||||||
|
mode: 0644
|
||||||
|
when:
|
||||||
|
- flibusta_source_archives_dir is defined
|
||||||
|
- flibusta_source_archives_dir != ""
|
||||||
|
- lookup('fileglob', flibusta_source_archives_dir + '/*.zip', wantlist=True) | length > 0
|
||||||
|
|
||||||
|
- name: Set write permissions for required directories
|
||||||
|
file:
|
||||||
|
path: "{{ flibusta_base_dir }}/{{ item }}"
|
||||||
|
mode: 0777
|
||||||
|
recurse: yes
|
||||||
|
loop:
|
||||||
|
- "cache"
|
||||||
|
- "FlibustaSQL"
|
||||||
|
|
||||||
|
- name: Set execute permissions for scripts
|
||||||
|
file:
|
||||||
|
path: "{{ flibusta_base_dir }}/{{ item }}"
|
||||||
|
mode: 0755
|
||||||
|
loop:
|
||||||
|
- "getcovers.sh"
|
||||||
|
- "getsql.sh"
|
||||||
|
- "update_daily.sh"
|
||||||
|
when: lookup('file', flibusta_base_dir + '/' + item, errors='ignore') != ''
|
||||||
|
|
||||||
|
- name: Check and set execute permissions for import.php
|
||||||
|
file:
|
||||||
|
path: "{{ flibusta_base_dir }}/application/tools/import.php"
|
||||||
|
mode: 0755
|
||||||
|
when: lookup('file', flibusta_base_dir + '/application/tools/import.php', errors='ignore') != ''
|
||||||
|
|
||||||
|
- name: Deploy Flibusta docker-compose.yml
|
||||||
template:
|
template:
|
||||||
src: docker-compose.yml.j2
|
src: docker-compose.yml.j2
|
||||||
dest: "{{ flibusta_base_dir }}/docker-compose.yml"
|
dest: "{{ flibusta_base_dir }}/docker-compose.yml"
|
||||||
owner: root
|
mode: 0644
|
||||||
group: root
|
|
||||||
mode: '0644'
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Pull and deploy Flibusta container via docker-compose
|
- name: Build Flibusta containers
|
||||||
community.docker.docker_compose_v2:
|
community.docker.docker_compose_v2:
|
||||||
project_src: "{{ flibusta_base_dir }}"
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
pull: always
|
build: true
|
||||||
become: yes
|
state: present
|
||||||
|
register: build_result
|
||||||
|
|
||||||
|
- name: Start Flibusta services
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ flibusta_base_dir }}"
|
||||||
|
state: present
|
||||||
|
restarted: false
|
||||||
|
scale: {}
|
||||||
|
register: start_result
|
||||||
|
|
||||||
|
- name: Wait for services to start
|
||||||
|
pause:
|
||||||
|
seconds: 30
|
||||||
|
|
||||||
|
- name: Check if database needs initialization
|
||||||
|
shell: |
|
||||||
|
docker exec flibusta_postgres psql -U {{ flibusta_db_user }} -d {{ flibusta_db_name }} -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public';"
|
||||||
|
register: db_tables
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Display database status
|
||||||
|
debug:
|
||||||
|
msg: "Database tables count: {{ db_tables.stdout | default('Database not ready') }}"
|
||||||
|
|
||||||
|
- name: Check Flibusta services status
|
||||||
|
shell: |
|
||||||
|
docker ps --filter "name=flibusta" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||||
|
register: flibusta_status
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Display services status
|
||||||
|
debug:
|
||||||
|
var: flibusta_status.stdout_lines
|
||||||
|
|
||||||
|
- name: Display access information
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
Flibusta успешно развернута!
|
||||||
|
|
||||||
|
Сервисы:
|
||||||
|
1. Web-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }} (45135)
|
||||||
|
- OPDS каталог: http://{{ ansible_host }}:{{ flibusta_web_port }}/opds/
|
||||||
|
|
||||||
|
2. PostgreSQL БД: порт {{ flibusta_db_port }}
|
||||||
|
- Пользователь: {{ flibusta_db_user }}
|
||||||
|
- Пароль: {{ flibusta_db_password }}
|
||||||
|
- База данных: {{ flibusta_db_name }}
|
||||||
|
|
||||||
|
Дополнительно:
|
||||||
|
- SQL файлы размещены в: {{ flibusta_base_dir }}/FlibustaSQL/
|
||||||
|
- ZIP архивы в: {{ flibusta_base_dir }}/Flibusta.Net/
|
||||||
|
- Кэш: {{ flibusta_base_dir }}/cache/
|
||||||
|
- Данные БД: {{ flibusta_base_dir }}/db/
|
||||||
|
|
||||||
|
Для обновления базы данных:
|
||||||
|
1. Разместите новые файлы в соответствующих каталогах
|
||||||
|
2. Выполните через веб-интерфейс: "Сервис" → "Обновление базы"
|
||||||
@ -1,28 +1,66 @@
|
|||||||
version: '3.8'
|
version: '3.1'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
flibusta:
|
postgres:
|
||||||
image: "{{ flibusta_image }}"
|
build: phpdocker/pg
|
||||||
container_name: flibusta
|
container_name: flibusta_postgres
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
mem_limit: "2g"
|
working_dir: /application
|
||||||
security_opt:
|
volumes:
|
||||||
- no-new-privileges:true
|
- './db:/var/lib/postgresql/data'
|
||||||
ports:
|
- './application:/application'
|
||||||
- "{{ int_ip }}:{{ flibusta_port }}:8080"
|
environment:
|
||||||
environment:
|
- POSTGRES_USER={{ flibusta_db_user }}
|
||||||
- TZ={{ timezone }}
|
- POSTGRES_PASSWORD={{ flibusta_db_password }}
|
||||||
- WEBDAV_ENABLED={{ flibusta_webdav_enabled | lower }}
|
- POSTGRES_DB={{ flibusta_db_name }}
|
||||||
- OPDS_ENABLED={{ flibusta_opds_enabled | lower }}
|
- TZ={{ timezone }}
|
||||||
volumes:
|
- PUID=1000
|
||||||
- "{{ flibusta_base_dir }}/config:/app/config:rw"
|
- PGID=1000
|
||||||
- "{{ flibusta_base_dir }}/data:/app/rw:rw"
|
ports:
|
||||||
- "{{ flibusta_books_dir }}:/books:rw"
|
- '{{ flibusta_db_port }}:5432'
|
||||||
{% if flibusta_calibre_integration %}
|
networks:
|
||||||
- "{{ calibre_library_dir }}:/calibre:ro"
|
- flibusta_network
|
||||||
{% endif %}
|
|
||||||
healthcheck:
|
webserver:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
image: 'nginx:alpine'
|
||||||
interval: 30s
|
container_name: flibusta_nginx
|
||||||
timeout: 10s
|
restart: unless-stopped
|
||||||
retries: 3
|
working_dir: /application
|
||||||
start_period: 40s
|
volumes:
|
||||||
|
- './application:/application'
|
||||||
|
- './cache:/application/cache'
|
||||||
|
- './Flibusta.Net:/application/flibusta'
|
||||||
|
- './FlibustaSQL/lib.a.attached.zip:/application/cache/lib.a.attached.zip'
|
||||||
|
- './FlibustaSQL/lib.b.attached.zip:/application/cache/lib.b.attached.zip'
|
||||||
|
- './phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
|
||||||
|
ports:
|
||||||
|
- '{{ flibusta_web_port }}:80'
|
||||||
|
depends_on:
|
||||||
|
- php-fpm
|
||||||
|
networks:
|
||||||
|
- flibusta_network
|
||||||
|
|
||||||
|
php-fpm:
|
||||||
|
build: phpdocker/php-fpm
|
||||||
|
container_name: flibusta_php
|
||||||
|
restart: unless-stopped
|
||||||
|
working_dir: /application
|
||||||
|
volumes:
|
||||||
|
- './application:/application'
|
||||||
|
- './cache:/application/cache'
|
||||||
|
- './FlibustaSQL/lib.a.attached.zip:/application/cache/lib.a.attached.zip'
|
||||||
|
- './FlibustaSQL/lib.b.attached.zip:/application/cache/lib.b.attached.zip'
|
||||||
|
- './Flibusta.Net:/application/flibusta'
|
||||||
|
- './FlibustaSQL:/application/sql'
|
||||||
|
- './blob:/application/blob'
|
||||||
|
- './phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini'
|
||||||
|
environment:
|
||||||
|
- TZ={{ timezone }}
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
networks:
|
||||||
|
- flibusta_network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
flibusta_network:
|
||||||
|
driver: bridge
|
||||||
Loading…
Reference in New Issue
Block a user