olimp/arhive_roles/flibusta/tasks/main.yml
Administrator 3f3b04fba1 Update 10 files
- /roles/teamspeak/tasks/main.yml
- /roles/teamspeak/templates/docker-compose.yml.j2
- /roles/flibusta/handlers/main.yml
- /roles/flibusta/tasks/main.yml
- /roles/flibusta/templates/docker-compose.yml.j2
- /arhive_roles/teamspeak/tasks/main.yml
- /arhive_roles/teamspeak/templates/docker-compose.yml.j2
- /arhive_roles/flibusta/handlers/main.yml
- /arhive_roles/flibusta/tasks/main.yml
- /arhive_roles/flibusta/templates/docker-compose.yml.j2
2026-03-24 09:17:59 +05:00

163 lines
5.1 KiB
YAML

---
- name: Check if Flibusta repository exists
stat:
path: "{{ flibusta_base_dir }}/docker-compose.yml"
register: flibusta_repo
- 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"
- "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 }}/"
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"
- "blob"
- name: Set execute permissions for scripts (if exist)
block:
- name: Check which scripts exist
find:
paths: "{{ flibusta_base_dir }}"
patterns: "*.sh"
file_type: file
register: found_scripts
- name: Set permissions for found scripts
file:
path: "{{ item.path }}"
mode: 0755
loop: "{{ found_scripts.files }}"
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
# Используем прямую сборку и запуск через shell для лучшего контроля
- name: Build Flibusta containers
shell: |
cd {{ flibusta_base_dir }}
docker compose build --no-cache
args:
executable: /bin/bash
register: build_result
- name: Start Flibusta services
community.docker.docker_compose_v2:
project_src: "{{ flibusta_base_dir }}"
state: present
- name: Wait for services to stabilize
pause:
seconds: 45
- name: Check container statuses
shell: |
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 container information
debug:
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 развернута!
Доступ:
- Web-интерфейс: http://{{ ansible_host }}:{{ flibusta_web_port }}
- OPDS каталог: http://{{ ansible_host }}:{{ flibusta_web_port }}/opds/
- PostgreSQL БД: порт {{ flibusta_db_port }}
Для завершения установки:
1. Дождитесь полной инициализации контейнеров (может занять несколько минут)
2. Откройте веб-интерфейс
3. Перейдите в меню "Сервис" → "Обновление базы"
Если PostgreSQL не запускается, проверьте:
- Права на каталог {{ flibusta_base_dir }}/db
- Достаточно ли места на диске
- Логи контейнера: docker logs flibusta_postgres