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_opds: true
|
||||
|
||||
flibusta_base_dir: "{{ service_config_base }}/flibusta"
|
||||
flibusta_books_dir: "/mnt/books/flibusta"
|
||||
flibusta_port: "45135"
|
||||
flibusta_image: "flibusta/fb_tools:full-latest"
|
||||
flibusta_webdav_enabled: true
|
||||
flibusta_opds_enabled: true
|
||||
flibusta_calibre_integration: true
|
||||
# ------------ Flibusta ------------
|
||||
flibusta_base_dir: "/mnt/service/flibusta"
|
||||
flibusta_source_archives_dir: "/mnt/books/flibusta"
|
||||
flibusta_web_port: "45135"
|
||||
flibusta_db_port: "45136"
|
||||
flibusta_db_user: "flibusta"
|
||||
flibusta_db_password: "flibusta"
|
||||
flibusta_db_name: "flibusta"
|
||||
|
||||
# ------------ photo (192.168.1.204) ------------
|
||||
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
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- "{{ flibusta_base_dir }}/config"
|
||||
- "{{ flibusta_base_dir }}/data"
|
||||
- "{{ flibusta_books_dir }}"
|
||||
become: yes
|
||||
- name: Check if Flibusta repository exists
|
||||
stat:
|
||||
path: "{{ flibusta_base_dir }}/docker-compose.yml"
|
||||
register: flibusta_repo
|
||||
|
||||
- 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:
|
||||
src: docker-compose.yml.j2
|
||||
dest: "{{ flibusta_base_dir }}/docker-compose.yml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
become: yes
|
||||
mode: 0644
|
||||
|
||||
- name: Pull and deploy Flibusta container via docker-compose
|
||||
- name: Build Flibusta containers
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ flibusta_base_dir }}"
|
||||
pull: always
|
||||
become: yes
|
||||
build: true
|
||||
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:
|
||||
flibusta:
|
||||
image: "{{ flibusta_image }}"
|
||||
container_name: flibusta
|
||||
restart: unless-stopped
|
||||
mem_limit: "2g"
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
ports:
|
||||
- "{{ int_ip }}:{{ flibusta_port }}:8080"
|
||||
environment:
|
||||
- TZ={{ timezone }}
|
||||
- WEBDAV_ENABLED={{ flibusta_webdav_enabled | lower }}
|
||||
- OPDS_ENABLED={{ flibusta_opds_enabled | lower }}
|
||||
volumes:
|
||||
- "{{ flibusta_base_dir }}/config:/app/config:rw"
|
||||
- "{{ flibusta_base_dir }}/data:/app/rw:rw"
|
||||
- "{{ flibusta_books_dir }}:/books:rw"
|
||||
{% if flibusta_calibre_integration %}
|
||||
- "{{ calibre_library_dir }}:/calibre:ro"
|
||||
{% endif %}
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
postgres:
|
||||
build: phpdocker/pg
|
||||
container_name: flibusta_postgres
|
||||
restart: unless-stopped
|
||||
working_dir: /application
|
||||
volumes:
|
||||
- './db:/var/lib/postgresql/data'
|
||||
- './application:/application'
|
||||
environment:
|
||||
- POSTGRES_USER={{ flibusta_db_user }}
|
||||
- POSTGRES_PASSWORD={{ flibusta_db_password }}
|
||||
- POSTGRES_DB={{ flibusta_db_name }}
|
||||
- TZ={{ timezone }}
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
ports:
|
||||
- '{{ flibusta_db_port }}:5432'
|
||||
networks:
|
||||
- flibusta_network
|
||||
|
||||
webserver:
|
||||
image: 'nginx:alpine'
|
||||
container_name: flibusta_nginx
|
||||
restart: unless-stopped
|
||||
working_dir: /application
|
||||
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