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
- name: rebuild flibusta
community.docker.docker_compose_v2:
project_src: "{{ flibusta_base_dir }}"
state: present
build: "always"
restarted: true
shell: |
cd {{ flibusta_base_dir }}
docker compose down
docker compose build --no-cache
docker compose up -d
args:
executable: /bin/bash
- name: stop flibusta
community.docker.docker_compose_v2:
@ -22,10 +24,23 @@
project_src: "{{ flibusta_base_dir }}"
state: present
- name: update flibusta database via web
debug:
msg: |
Для обновления базы данных Flibusta выполните:
1. Зайдите в веб-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }}
2. Перейдите в меню "Сервис"
3. Нажмите "Обновление базы"
- name: show flibusta logs
shell: |
echo "=== PostgreSQL ==="
docker logs flibusta_postgres --tail 50
echo ""
echo "=== PHP-FPM ==="
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"
- "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
copy:
src: "{{ flibusta_source_archives_dir }}/"
@ -75,85 +83,81 @@
label: "{{ item.path | basename }}"
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
template:
src: docker-compose.yml.j2
dest: "{{ flibusta_base_dir }}/docker-compose.yml"
mode: 0644
# Вариант 1: Сборка и запуск в одной задаче (рекомендуется для первого запуска)
- name: Build and start 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 для лучшего контроля
- name: Build Flibusta containers
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:
executable: /bin/bash
register: db_ready
ignore_errors: yes
register: build_result
- name: Display database status
debug:
msg: "Database is {{ 'ready' if db_ready.rc == 0 else 'not ready yet' }}"
- name: Start Flibusta services
community.docker.docker_compose_v2:
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: |
docker ps --filter "name=flibusta" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
register: flibusta_status
echo "=== Flibusta Containers 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
- name: Display services status
- name: Display container information
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
debug:
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/
- PostgreSQL БД: порт {{ flibusta_db_port }}
2. PostgreSQL БД: порт {{ flibusta_db_port }}
- Пользователь: {{ flibusta_db_user }}
- Пароль: {{ flibusta_db_password }}
- База данных: {{ flibusta_db_name }}
Для завершения установки:
1. Дождитесь полной инициализации контейнеров (может занять несколько минут)
2. Откройте веб-интерфейс
3. Перейдите в меню "Сервис" → "Обновление базы"
Дополнительно:
- SQL файлы размещены в: {{ flibusta_base_dir }}/FlibustaSQL/
- ZIP архивы в: {{ flibusta_base_dir }}/Flibusta.Net/
- Кэш: {{ flibusta_base_dir }}/cache/
- Данные БД: {{ flibusta_base_dir }}/db/
Для обновления базы данных:
1. Разместите новые файлы в соответствующих каталогах
2. Выполните через веб-интерфейс: "Сервис" → "Обновление базы"
Если PostgreSQL не запускается, проверьте:
- Права на каталог {{ flibusta_base_dir }}/db
- Достаточно ли места на диске
- Логи контейнера: docker logs flibusta_postgres

View File

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