- /group_vars/all.yml - /roles/flibusta/tasks/main.yml - /roles/flibusta/handlers/main.yml - /roles/flibusta/templates/docker-compose.yml.j2
141 lines
4.4 KiB
YAML
141 lines
4.4 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"
|
|
|
|
- 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"
|
|
|
|
- name: Set execute permissions for scripts
|
|
file:
|
|
path: "{{ flibusta_base_dir }}/{{ item }}"
|
|
mode: 0755
|
|
loop:
|
|
- "getcovers.sh"
|
|
- "getsql.sh"
|
|
- "update_daily.sh"
|
|
when: lookup('file', flibusta_base_dir + '/' + item, errors='ignore') != ''
|
|
|
|
- name: Check and set execute permissions for import.php
|
|
file:
|
|
path: "{{ flibusta_base_dir }}/application/tools/import.php"
|
|
mode: 0755
|
|
when: lookup('file', flibusta_base_dir + '/application/tools/import.php', errors='ignore') != ''
|
|
|
|
- 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 needs initialization
|
|
shell: |
|
|
docker exec flibusta_postgres psql -U {{ flibusta_db_user }} -d {{ flibusta_db_name }} -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public';"
|
|
register: db_tables
|
|
ignore_errors: yes
|
|
|
|
- name: Display database status
|
|
debug:
|
|
msg: "Database tables count: {{ db_tables.stdout | default('Database not ready') }}"
|
|
|
|
- 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. Выполните через веб-интерфейс: "Сервис" → "Обновление базы" |