mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
116 lines
4.1 KiB
YAML
116 lines
4.1 KiB
YAML
- name: Install ImageMagick package (debuntu)
|
|
package:
|
|
name: imagemagick
|
|
state: present
|
|
when: is_debuntu | bool
|
|
|
|
- name: Allow ImageMagick to read PDFs (debuntu)
|
|
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
|
|
when: is_debuntu | bool
|
|
|
|
- name: "Create 3 Calibre-Web folders to store data and configuration files: {{ calibreweb_home }}, {{ calibreweb_venv_path }}, {{ calibreweb_config }}"
|
|
file:
|
|
path: "{{ item }}"
|
|
owner: "{{ calibreweb_user }}"
|
|
group: "{{ apache_user }}"
|
|
mode: '0755'
|
|
state: directory
|
|
with_items:
|
|
- "{{ calibreweb_home }}"
|
|
- "{{ calibreweb_venv_path }}"
|
|
- "{{ calibreweb_config }}"
|
|
|
|
## TODO: Calibre-web future release might get into pypi https://github.com/janeczku/calibre-web/issues/456
|
|
- name: Download Calibre-Web github repository to {{ calibreweb_venv_path }}
|
|
git:
|
|
repo: https://github.com/janeczku/calibre-web.git
|
|
dest: "{{ calibreweb_venv_path }}"
|
|
force: yes
|
|
#update: yes # not needed, as Ansible's default is to update
|
|
depth: 1
|
|
version: "{{ calibreweb_version }}"
|
|
when: internet_available | bool
|
|
|
|
## 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.
|
|
- name: Download Calibre-Web dependencies (using pip) into virtual environment
|
|
pip:
|
|
requirements: "{{ calibreweb_venv_path }}/requirements.txt"
|
|
virtualenv: "{{ calibreweb_venv_path }}"
|
|
virtualenv_site_packages: no
|
|
virtualenv_command: /usr/bin/virtualenv
|
|
virtualenv_python: python2.7
|
|
when: internet_available | bool
|
|
|
|
- name: Symlink {{ calibreweb_venv_path }}/vendor to {{ calibreweb_venv_path }}/lib/python2.7/site-packages to keep cps.py happy
|
|
file:
|
|
src: "{{ calibreweb_venv_path }}/lib/python2.7/site-packages"
|
|
dest: "{{ calibreweb_venv_path }}/vendor"
|
|
state: link
|
|
|
|
- name: Install unit file /etc/systemd/system/calibre-web.service & /etc/apache2/sites-available/calibre-web.conf for http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} from templates
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
with_items:
|
|
- { src: 'calibre-web.service.j2', dest: '/etc/systemd/system/calibre-web.service' }
|
|
- { src: 'calibre-web.conf.j2', dest: '/etc/apache2/sites-available/calibre-web.conf' }
|
|
when: apache_install | bool
|
|
|
|
- name: Does /library/calibre-web/metadata.db exist?
|
|
stat:
|
|
path: /library/calibre-web/metadata.db
|
|
register: metadatadb
|
|
|
|
- name: Provision/Copy both default metadata files into /library/calibre-web IF metadata.db did not exist
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: "{{ calibreweb_home }}"
|
|
owner: "{{ calibreweb_user }}"
|
|
group: "{{ apache_user }}"
|
|
mode: '0644'
|
|
backup: yes
|
|
with_items:
|
|
- roles/calibre-web/files/metadata.db
|
|
- roles/calibre-web/files/metadata_db_prefs_backup.json
|
|
when: not metadatadb.stat.exists
|
|
#when: calibreweb_provision | bool
|
|
|
|
- name: Provision/Copy default admin settings to {{ calibreweb_config }}/app.db IF metadata.db did not exist # {{ calibreweb_config }} is /library/calibre-web/config
|
|
copy:
|
|
src: roles/calibre-web/files/app.db
|
|
dest: "{{ calibreweb_config }}"
|
|
owner: "{{ calibreweb_user }}"
|
|
group: "{{ apache_user }}"
|
|
mode: '0644'
|
|
backup: yes
|
|
when: not metadatadb.stat.exists
|
|
#when: calibreweb_provision | bool
|
|
|
|
|
|
# RECORD Calibre-Web AS INSTALLED
|
|
|
|
- name: "Set 'calibreweb_installed: True'"
|
|
set_fact:
|
|
calibreweb_installed: True
|
|
|
|
- name: "Add 'calibreweb_installed: True' to {{ iiab_state_file }}"
|
|
lineinfile:
|
|
dest: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
regexp: '^calibreweb_installed'
|
|
line: 'calibreweb_installed: True'
|