olimp/roles/flibusta/tasks/main.yml
Administrator 4ea0230b03 Update 2 files
- /roles/flibusta/tasks/main.yml
- /roles/flibusta/handlers/main.yml
2025-12-05 14:17:35 +05:00

159 lines
5.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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: 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: 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: |
timeout 30 sh -c 'until docker exec flibusta_postgres pg_isready -U {{ flibusta_db_user }}; do sleep 2; done'
args:
executable: /bin/bash
register: db_ready
ignore_errors: yes
- name: Display database status
debug:
msg: "Database is {{ 'ready' if db_ready.rc == 0 else 'not ready yet' }}"
- 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. Выполните через веб-интерфейс: "Сервис" → "Обновление базы"