1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/calibre-web/tasks/install.yml

108 lines
4.2 KiB
YAML
Raw Normal View History

- name: "Install packages: imagemagick, python3-venv"
2019-09-14 22:09:30 +00:00
package:
name:
- imagemagick
- python3-venv
2019-09-14 22:09:30 +00:00
state: present
2020-02-02 17:30:19 +00:00
- name: Allow ImageMagick to read PDFs, per /etc/ImageMagick-6/policy.xml, to create book cover thumbnails
2019-09-14 22:09:30 +00:00
lineinfile:
path: /etc/ImageMagick-6/policy.xml
regexp: '<policy domain="coder" rights="none" pattern="PDF" />'
backrefs: yes
line: ' <policy domain="coder" rights="read" pattern="PDF" />'
state: present
- name: "Create 3 Calibre-Web folders to store data and config files: {{ calibreweb_home }}, {{ calibreweb_venv_path }}, {{ calibreweb_config }} (all set to {{ calibreweb_user }}:{{ apache_user }}) (default to 0755)"
2019-09-14 22:09:30 +00:00
file:
2020-02-02 17:30:19 +00:00
state: directory
2019-09-14 22:09:30 +00:00
path: "{{ item }}"
2020-02-02 17:30:19 +00:00
owner: "{{ calibreweb_user }}" # root
group: "{{ apache_user }}" # www-data on debuntu
2019-09-14 22:09:30 +00:00
with_items:
2020-02-02 17:30:19 +00:00
- "{{ calibreweb_home }}" # /library/calibre-web
- "{{ calibreweb_config }}" # /library/calibre-web/config
- "{{ calibreweb_venv_path }}" # /usr/local/calibre-web-py3
2019-09-14 22:09:30 +00:00
## TODO: Calibre-web future release might get into pypi https://github.com/janeczku/calibre-web/issues/456
- name: Clone i.e. download Calibre-Web ({{ calibreweb_version }}) from https://github.com/janeczku/calibre-web.git to {{ calibreweb_venv_path }} (~94 MB initially, ~115+ MB later)
2019-09-14 22:09:30 +00:00
git:
repo: https://github.com/janeczku/calibre-web.git
dest: "{{ calibreweb_venv_path }}"
2019-09-14 22:09:30 +00:00
force: yes
depth: 1
version: "{{ calibreweb_version }}" # e.g. master, 0.6.17
2019-09-14 22:09:30 +00:00
## Ansible Pip Bug: Cannot use 'chdir' with 'env' https://github.com/ansible/ansible/issues/37912 (Patch landed)
#- name: Download calibre-web dependencies into vendor subdirectory.
# pip:
# requirements: "{{ calibreweb_path }}/requirements.txt"
# chdir: "{{ calibreweb_path }}"
# extra_args: '--target vendor'
# ignore_errors: True
##
# Implementing this with Ansible command module for now.
2020-02-14 07:04:45 +00:00
- name: Download Calibre-Web dependencies (using pip) into python3 virtual environment {{ calibreweb_venv_path }}
pip:
2019-09-14 22:09:30 +00:00
requirements: "{{ calibreweb_venv_path }}/requirements.txt"
2020-02-06 12:19:05 +00:00
virtualenv: "{{ calibreweb_venv_path }}" # /usr/local/calibre-web-py3
2019-09-14 22:09:30 +00:00
virtualenv_site_packages: no
virtualenv_command: python3 -m venv {{ calibreweb_venv_path }}
# VIRTUALENV EXAMPLE COMMANDS:
# cd /usr/local/calibre-web-py3
# source bin/activate
# python3 -m pip list ('pip list' probably sufficient, likewise below)
# python3 -m pip freeze > /tmp/requirements.txt
# python3 -m pip install -r requirements.txt
# deactivate
# https://pip.pypa.io/en/latest/user_guide/#requirements-files
2019-09-14 22:09:30 +00:00
2020-02-02 17:30:19 +00:00
- name: Install /etc/systemd/system/calibre-web.service from template
2019-09-14 22:09:30 +00:00
template:
2020-02-02 17:30:19 +00:00
src: calibre-web.service.j2
dest: /etc/systemd/system/calibre-web.service
2019-09-14 22:09:30 +00:00
- name: Does /library/calibre-web/metadata.db exist?
stat:
path: /library/calibre-web/metadata.db
register: metadatadb
2020-02-02 17:48:20 +00:00
- name: Provision/Copy both default metadata files (metadata.db, metadata_db_prefs_backup.json) into {{ calibreweb_home }} IF metadata.db did not exist
2019-09-14 22:09:30 +00:00
copy:
src: "{{ item }}"
2020-02-02 17:30:19 +00:00
dest: "{{ calibreweb_home }}" # /library/calibre-web
owner: "{{ calibreweb_user }}" # root
group: "{{ apache_user }}" # www-data on debuntu
2019-09-14 22:09:30 +00:00
backup: yes
with_items:
- roles/calibre-web/files/metadata.db
- roles/calibre-web/files/metadata_db_prefs_backup.json
when: not metadatadb.stat.exists
- name: Does /library/calibre-web/config/app.db exist?
stat:
path: /library/calibre-web/config/app.db
register: appdb
- name: Provision/Copy default admin settings to {{ calibreweb_config }}/app.db IF it did not exist
2019-09-14 22:09:30 +00:00
copy:
src: roles/calibre-web/files/app.db
2020-02-02 17:30:19 +00:00
dest: "{{ calibreweb_config }}" # /library/calibre-web/config
owner: "{{ calibreweb_user }}" # root
group: "{{ apache_user }}" # www-data on debuntu
2019-09-14 22:09:30 +00:00
backup: yes
when: not appdb.stat.exists
2019-09-14 22:09:30 +00:00
2020-01-30 09:00:00 +00:00
# RECORD Calibre-Web AS INSTALLED
- name: "Set 'calibreweb_installed: True'"
set_fact:
calibreweb_installed: True
- name: "Add 'calibreweb_installed: True' to {{ iiab_state_file }}"
2019-09-14 22:09:30 +00:00
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-09-14 22:09:30 +00:00
regexp: '^calibreweb_installed'
2019-10-07 17:11:21 +00:00
line: 'calibreweb_installed: True'