Update 3 files

- /roles/flibusta/tasks/main.yml
- /roles/flibusta/handlers/main.yml
- /roles/flibusta/templates/docker-compose.yml.j2
This commit is contained in:
Administrator 2025-12-05 15:16:15 +05:00
parent 4ea0230b03
commit 42b8da556f
3 changed files with 104 additions and 75 deletions

View File

@ -6,11 +6,13 @@
restarted: true restarted: true
- name: rebuild flibusta - name: rebuild flibusta
community.docker.docker_compose_v2: shell: |
project_src: "{{ flibusta_base_dir }}" cd {{ flibusta_base_dir }}
state: present docker compose down
build: "always" docker compose build --no-cache
restarted: true docker compose up -d
args:
executable: /bin/bash
- name: stop flibusta - name: stop flibusta
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
@ -22,10 +24,23 @@
project_src: "{{ flibusta_base_dir }}" project_src: "{{ flibusta_base_dir }}"
state: present state: present
- name: update flibusta database via web - name: show flibusta logs
debug: shell: |
msg: | echo "=== PostgreSQL ==="
Для обновления базы данных Flibusta выполните: docker logs flibusta_postgres --tail 50
1. Зайдите в веб-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }} echo ""
2. Перейдите в меню "Сервис" echo "=== PHP-FPM ==="
3. Нажмите "Обновление базы" docker logs flibusta_php --tail 50
echo ""
echo "=== Nginx ==="
docker logs flibusta_nginx --tail 50
args:
executable: /bin/bash
- name: fix postgres permissions
file:
path: "{{ flibusta_base_dir }}/db"
owner: "999"
group: "999"
mode: 0755
recurse: yes

View File

@ -25,6 +25,14 @@
- "blob" - "blob"
- "application/tools" - "application/tools"
- name: Set correct ownership for db directory
file:
path: "{{ flibusta_base_dir }}/db"
owner: "999" # PostgreSQL внутри контейнера обычно работает от postgres (UID 999)
group: "999"
mode: 0755
recurse: yes
- name: Copy SQL files from source directory - name: Copy SQL files from source directory
copy: copy:
src: "{{ flibusta_source_archives_dir }}/" src: "{{ flibusta_source_archives_dir }}/"
@ -75,85 +83,81 @@
label: "{{ item.path | basename }}" label: "{{ item.path | basename }}"
when: flibusta_base_dir is defined when: flibusta_base_dir is defined
- name: Set execute permissions for PHP tools (if exist)
block:
- name: Find PHP tools
find:
paths: "{{ flibusta_base_dir }}/application/tools"
patterns: "*.php"
file_type: file
register: php_tools
ignore_errors: yes
- name: Set permissions for PHP tools
file:
path: "{{ item.path }}"
mode: 0755
loop: "{{ php_tools.files | default([]) }}"
loop_control:
label: "{{ item.path | basename }}"
when: flibusta_base_dir is defined
- name: Deploy Flibusta docker-compose.yml - 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"
mode: 0644 mode: 0644
# Вариант 1: Сборка и запуск в одной задаче (рекомендуется для первого запуска) # Используем прямую сборку и запуск через shell для лучшего контроля
- name: Build and start Flibusta containers - name: Build Flibusta containers
community.docker.docker_compose_v2:
project_src: "{{ flibusta_base_dir }}"
build: "always" # Изменили с True на "always"
state: present
register: build_result
- name: Wait for services to start
pause:
seconds: 30
- name: Check if database is accessible
shell: | shell: |
timeout 30 sh -c 'until docker exec flibusta_postgres pg_isready -U {{ flibusta_db_user }}; do sleep 2; done' cd {{ flibusta_base_dir }}
docker compose build --no-cache
args: args:
executable: /bin/bash executable: /bin/bash
register: db_ready register: build_result
ignore_errors: yes
- name: Display database status - name: Start Flibusta services
debug: community.docker.docker_compose_v2:
msg: "Database is {{ 'ready' if db_ready.rc == 0 else 'not ready yet' }}" project_src: "{{ flibusta_base_dir }}"
state: present
- name: Check Flibusta services status - name: Wait for services to stabilize
pause:
seconds: 45
- name: Check container statuses
shell: | shell: |
docker ps --filter "name=flibusta" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" echo "=== Flibusta Containers Status ==="
register: flibusta_status docker ps --filter name=flibusta --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo ""
echo "=== PostgreSQL Logs (last 20 lines) ==="
docker logs flibusta_postgres --tail 20 2>/dev/null || echo "PostgreSQL logs not available"
echo ""
echo "=== PHP-FPM Logs (last 20 lines) ==="
docker logs flibusta_php --tail 20 2>/dev/null || echo "PHP-FPM logs not available"
echo ""
echo "=== Nginx Logs (last 20 lines) ==="
docker logs flibusta_nginx --tail 20 2>/dev/null || echo "Nginx logs not available"
args:
executable: /bin/bash
register: container_info
changed_when: false changed_when: false
- name: Display services status - name: Display container information
debug: debug:
var: flibusta_status.stdout_lines var: container_info.stdout
- name: Check if web interface is accessible
wait_for:
host: "127.0.0.1"
port: "{{ flibusta_web_port }}"
timeout: 30
delay: 5
ignore_errors: yes
register: web_check
- name: Display web interface status
debug:
msg: "Web interface is {{ 'accessible' if web_check.success else 'not accessible yet' }}"
- name: Display access information - name: Display access information
debug: debug:
msg: | msg: |
Flibusta успешно развернута! Flibusta развернута!
Сервисы: Доступ:
1. Web-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }} (45135) - Web-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }}
- OPDS каталог: http://{{ ansible_host }}:{{ flibusta_web_port }}/opds/ - OPDS каталог: http://{{ ansible_host }}:{{ flibusta_web_port }}/opds/
- PostgreSQL БД: порт {{ flibusta_db_port }}
2. PostgreSQL БД: порт {{ flibusta_db_port }} Для завершения установки:
- Пользователь: {{ flibusta_db_user }} 1. Дождитесь полной инициализации контейнеров (может занять несколько минут)
- Пароль: {{ flibusta_db_password }} 2. Откройте веб-интерфейс
- База данных: {{ flibusta_db_name }} 3. Перейдите в меню "Сервис" → "Обновление базы"
Дополнительно: Если PostgreSQL не запускается, проверьте:
- SQL файлы размещены в: {{ flibusta_base_dir }}/FlibustaSQL/ - Права на каталог {{ flibusta_base_dir }}/db
- ZIP архивы в: {{ flibusta_base_dir }}/Flibusta.Net/ - Достаточно ли места на диске
- Кэш: {{ flibusta_base_dir }}/cache/ - Логи контейнера: docker logs flibusta_postgres
- Данные БД: {{ flibusta_base_dir }}/db/
Для обновления базы данных:
1. Разместите новые файлы в соответствующих каталогах
2. Выполните через веб-интерфейс: "Сервис" → "Обновление базы"

View File

@ -14,12 +14,18 @@ services:
- POSTGRES_PASSWORD={{ flibusta_db_password }} - POSTGRES_PASSWORD={{ flibusta_db_password }}
- POSTGRES_DB={{ flibusta_db_name }} - POSTGRES_DB={{ flibusta_db_name }}
- TZ={{ timezone }} - TZ={{ timezone }}
- PUID=1000 - PUID=999 # PostgreSQL обычно использует UID 999
- PGID=1000 - PGID=999
ports: ports:
- '{{ flibusta_db_port }}:5432' - '{{ flibusta_db_port }}:5432'
networks: networks:
- flibusta_network - flibusta_network
# Добавляем healthcheck для лучшего контроля
healthcheck:
test: ["CMD-SHELL", "pg_isready -U {{ flibusta_db_user }}"]
interval: 10s
timeout: 5s
retries: 5
webserver: webserver:
image: 'nginx:alpine' image: 'nginx:alpine'
@ -36,7 +42,8 @@ services:
ports: ports:
- '{{ flibusta_web_port }}:80' - '{{ flibusta_web_port }}:80'
depends_on: depends_on:
- php-fpm php-fpm:
condition: service_started
networks: networks:
- flibusta_network - flibusta_network
@ -58,6 +65,9 @@ services:
- TZ={{ timezone }} - TZ={{ timezone }}
- PUID=1000 - PUID=1000
- PGID=1000 - PGID=1000
depends_on:
postgres:
condition: service_healthy
networks: networks:
- flibusta_network - flibusta_network