1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/calibre/tasks/main.yml
2017-11-26 20:22:16 -05:00

98 lines
3.1 KiB
YAML

# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre-server etc) ON ALL OS'S
# RUNS IF /usr/bin/calibre-uninstall DOES NOT ALEADY EXIST
- name: Install Calibre via calibre-installer.py (OS's other than Raspbian)
include_tasks: py-installer.yml
when: (not is_rpi) and (not calibre_debs_on_debian)
#when: is_redhat or is_ubuntu
- name: Install Calibre via .debs (Raspbian)
include_tasks: debs.yml
when: is_rpi or calibre_debs_on_debian
#when: is_rpi or is_debian # (is_debian also covers & includes is_rpi)
# 2. STOP CALIBRE SERVICE IF IT EXISTS (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)
#- name: Check if Calibre systemd service exists
# stat:
# path: /etc/systemd/system/calibre-serve.service
# register: calibre_svc
- name: Stop Calibre service -- calibre-server by Kovid Goyal
# systemd:
service:
name: calibre-serve
state: stopped
#enabled: no
# register: command_result # gist.github.com/tyrells/0a79681de339237cb04c
failed_when: false # Never Fail during "systemctl stop calibre-serve" (even if service doesn't exist!)
# when: calibre_svc.stat.exists
# 3. CREATE DATABASE WITH A SAMPLE BOOK (REQUIRED AS OF CALIBRE 3.x)
- name: Check if /library/calibre/metadata.db exists
stat:
path: "{{ calibre_dbpath }}/metadata.db"
register: calibre_db
- name: Create database (required since Calibre 3.x) with a sample book
include_tasks: create-db.yml
when: not calibre_db.stat.exists
# 4. WRAP UP: CALIBRE SERVICE, http://box/books ETC
- name: Create calibre-serve.service and calibre.conf
template:
backup: no
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
with_items:
- { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service', mode: '0644'}
- { src: 'calibre.conf', dest: '/etc/{{ apache_config_dir }}', mode: '0644'}
when: calibre_enabled
# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/books ARE A MESS (BOOKS RARELY DISPLAY)
- name: Create calibre.conf link for UNTESTED http://box/books etc (debuntu)
file:
src: /etc/apache2/sites-available/calibre.conf
dest: /etc/apache2/sites-enabled/calibre.conf
state: link
when: calibre_enabled and is_debuntu
- name: Remove calibre.conf link if disabled (debuntu)
file:
dest: /etc/apache2/sites-enabled/calibre.conf
state: absent
when: (not calibre_enabled) and is_debuntu
- name: Enable Calibre service -- runs calibre-server by Kovid Goyal
service:
name: calibre-serve
enabled: yes
state: started
when: calibre_enabled
#async: 900
#poll: 5
- name: Add 'calibre' to list of services at /etc/iiab/iiab.ini
ini_file:
dest: "{{ service_filelist }}"
section: calibre
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: name
value: Calibre
- option: description
value: '"Calibre is an extremely popular personal library system for e-books."'
- option: url
value: "{{ calibre_src_url }}"
- option: database
value: "{{ calibre_dbpath }}"
- option: port
value: "{{ calibre_port }}"
- option: enabled
value: "{{ calibre_enabled }}"