--- - 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 - name: Build Flibusta containers community.docker.docker_compose_v2: project_src: "{{ flibusta_base_dir }}" 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 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. Выполните через веб-интерфейс: "Сервис" → "Обновление базы"