2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2023-07-15 15:20:17 +00:00
- name : "Install packages: ffmpeg, imagemagick, python3-netifaces"
2019-09-14 22:09:30 +00:00
package :
2020-03-09 17:51:26 +00:00
name :
2023-07-15 15:16:30 +00:00
- ffmpeg # 2023-07-15 : @deldesir requests this, so usability can be improved!
2020-03-09 17:51:26 +00:00
- imagemagick
2023-03-20 18:08:59 +00:00
- python3-netifaces
2019-09-14 22:09:30 +00:00
state : present
2023-03-20 03:18:48 +00:00
# https://github.com/iiab/iiab/pull/3496#issuecomment-1475094542
2023-03-20 18:08:59 +00:00
#- name: "Install packages: python3-dev, gcc to compile 'netifaces'"
# package:
# name:
# - python3-dev # header files
# - gcc # compiler
# state: present
# when: python_version is version('3.10', '>=')
2023-07-15 18:50:53 +00:00
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
2023-04-16 13:31:52 +00:00
- name : Remove previous virtual environment {{ calibreweb_venv_path }}
file :
path : "{{ calibreweb_venv_path }}"
state : absent
2021-07-06 21:59:07 +00:00
- 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
2020-05-17 02:48:52 +00:00
- "{{ calibreweb_venv_path }}" # /usr/local/calibre-web-py3
2019-09-14 22:09:30 +00:00
2023-07-15 18:50:53 +00:00
# FYI since May 2021, Calibre-Web (major releases) can be installed with pip:
# https://pypi.org/project/calibreweb/
# https://github.com/janeczku/calibre-web/issues/456
# https://github.com/janeczku/calibre-web/issues/677
# https://github.com/janeczku/calibre-web/pull/927
# https://github.com/janeczku/calibre-web/pull/1459
2023-07-15 03:01:55 +00:00
- name : Clone i.e. download Calibre-Web ({{ calibreweb_version }}) from {{ calibreweb_repo_url }} to {{ calibreweb_venv_path }} (~94 MB initially, ~115+ MB later)
2019-09-14 22:09:30 +00:00
git :
2023-07-15 02:30:01 +00:00
repo : "{{ calibreweb_repo_url }}" # e.g. https://github.com/janeczku/calibre-web
2022-03-07 14:22:46 +00:00
dest : "{{ calibreweb_venv_path }}"
2019-09-14 22:09:30 +00:00
force : yes
depth : 1
2023-07-15 02:42:16 +00:00
version : "{{ calibreweb_version }}" # e.g. master, 0.6.20
2019-09-14 22:09:30 +00:00
2023-03-20 03:18:48 +00:00
- name : Download Calibre-Web dependencies from 'requirements.txt' into python3 virtual environment {{ calibreweb_venv_path }}
2020-02-14 06:59:56 +00:00
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
2023-04-16 18:43:16 +00:00
virtualenv_command : python3 -m venv --system-site-packages {{ calibreweb_venv_path }}
2023-03-20 18:08:59 +00:00
2022-04-29 02:53:26 +00:00
# VIRTUALENV EXAMPLE COMMANDS:
# cd /usr/local/calibre-web-py3
2023-07-25 02:55:16 +00:00
# source bin/activate (prepends '/usr/local/calibre-web-py3/bin' to yr PATH)
# python3 -m pip list ('pip list' sufficient *IF* path set above!)
2022-04-29 02:53:26 +00:00
# python3 -m pip freeze > /tmp/requirements.txt
# python3 -m pip install -r requirements.txt
# deactivate
2023-07-25 02:55:16 +00:00
# https://pip.pypa.io/en/stable/user_guide/#requirements-files
# https://pip.pypa.io/en/latest/reference/requirements-file-format/
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
2022-03-07 14:43:41 +00:00
- 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
2022-03-07 14:43:41 +00:00
when : not appdb.stat.exists
2019-09-14 22:09:30 +00:00
2023-03-20 14:23:46 +00:00
2020-01-30 09:00:00 +00:00
# RECORD Calibre-Web AS INSTALLED
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'calibreweb_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : calibre-web
option : calibreweb_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2020-01-30 09:00:00 +00:00
- name : "Set 'calibreweb_installed: True'"
set_fact :
calibreweb_installed : True
2020-01-12 23:15:33 +00:00
- name : "Add 'calibreweb_installed: True' to {{ iiab_state_file }}"
2019-09-14 22:09:30 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
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 '