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

98 lines
3.1 KiB
YAML
Raw Normal View History

2017-11-20 08:26:48 +00:00
# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre-server etc) ON ALL OS'S
2017-05-27 18:09:50 +00:00
2017-11-20 08:01:38 +00:00
# RUNS IF /usr/bin/calibre-uninstall DOES NOT ALEADY EXIST
- name: Install Calibre via calibre-installer.py (OS's other than Raspbian)
2017-11-20 07:14:08 +00:00
include_tasks: py-installer.yml
when: is_redhat or is_ubuntu or (is_debian and not calibre_debs_on_debian)
#when: not is_rpi
2017-11-19 20:33:53 +00:00
2017-11-20 08:01:38 +00:00
- name: Install Calibre via .debs (Raspbian)
2017-11-19 20:33:53 +00:00
include_tasks: debs.yml
when: is_rpi or (is_debian and calibre_debs_on_debian)
#when: is_rpi or is_debian # (is_debian also covers & includes is_rpi)
2017-11-19 20:33:53 +00:00
2017-12-07 16:06:37 +00:00
- 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'}
# 2. STOP CALIBRE SERVICE IF IT EXISTS (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)
2017-11-20 08:25:53 +00:00
#- name: Check if Calibre systemd service exists
# stat:
# path: /etc/systemd/system/calibre-serve.service
# register: calibre_svc
2017-11-20 08:25:53 +00:00
- name: Stop Calibre service -- calibre-server by Kovid Goyal
# systemd:
2017-11-20 08:25:53 +00:00
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
2017-11-20 08:25:53 +00:00
# 3. CREATE DATABASE WITH A SAMPLE BOOK (REQUIRED AS OF CALIBRE 3.x)
2017-11-20 08:01:38 +00:00
- name: Check if /library/calibre/metadata.db exists
stat:
path: "{{ calibre_dbpath }}/metadata.db"
register: calibre_db
2017-11-20 08:13:00 +00:00
- name: Create database (required since Calibre 3.x) with a sample book
include_tasks: create-db.yml
2017-11-19 19:53:41 +00:00
when: not calibre_db.stat.exists
2017-05-27 18:09:50 +00:00
2017-11-20 08:32:40 +00:00
# 4. WRAP UP: CALIBRE SERVICE, http://box/books ETC
2017-05-27 18:09:50 +00:00
# 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
2017-05-27 18:09:50 +00:00
2017-11-20 08:01:38 +00:00
- name: Remove calibre.conf link if disabled (debuntu)
file:
dest: /etc/apache2/sites-enabled/calibre.conf
state: absent
2017-11-20 08:32:40 +00:00
when: (not calibre_enabled) and is_debuntu
2017-11-20 08:01:38 +00:00
- name: Enable Calibre service -- runs calibre-server by Kovid Goyal
service:
name: calibre-serve
enabled: yes
state: started
2017-05-27 18:09:50 +00:00
when: calibre_enabled
2017-11-20 08:03:25 +00:00
#async: 900
#poll: 5
2017-05-27 18:09:50 +00:00
2017-11-27 01:22:16 +00:00
- 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 }}"
2017-05-27 18:09:50 +00:00
with_items:
2017-11-27 01:22:16 +00:00
- 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 }}"