From eec76edd5f88eebe8c381d58d50b3bcda2f3132d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 19 Nov 2017 14:33:53 -0600 Subject: [PATCH] split off debs and installing --- roles/calibre/tasks/debs.yml | 8 +++ roles/calibre/tasks/install.yml | 92 ------------------------------- roles/calibre/tasks/installer.yml | 50 +++++++++++++++++ roles/calibre/tasks/main.yml | 10 +++- 4 files changed, 67 insertions(+), 93 deletions(-) create mode 100644 roles/calibre/tasks/debs.yml create mode 100644 roles/calibre/tasks/installer.yml diff --git a/roles/calibre/tasks/debs.yml b/roles/calibre/tasks/debs.yml new file mode 100644 index 000000000..f701daf9b --- /dev/null +++ b/roles/calibre/tasks/debs.yml @@ -0,0 +1,8 @@ +- name: Install Calibre (OS's other than CentOS) + package: name={{ item }} + state=present + with_items: + - calibre + +- name: Upgrade Calibre to 3.12 + command: scripts/calibre312.sh diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index 25e498906..b8596f8e3 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -1,90 +1,3 @@ -- name: Download latest linux-installer.py from GitHub to calibre-installer.py -# seems to work with just about any Linux, and deals with dependencies - get_url: - url: "{{ calibre_src_url }}" - dest: "{{ downloads_dir }}/calibre-installer.py" - mode: 0755 - force: yes - backup: yes - register: calibre_download_output - when: internet_available and is_redhat - -# ALWAYS DEFINED, DESPITE get_url DOCUMENTATION CLAIM... -# - debug: -# msg: "{{ calibre_download_output.src }}" -# -# DEFINED ONLY WHEN /opt/iiab/downloads/calibre-installer.py CHANGES -# - debug: -# msg: "{{ calibre_download_output.backup_file }}" - -# OOPS BAD IDEA: changes in https://github.com/kovidgoyal/calibre/commits/master/setup/linux-installer.py are not sync'd with Calibre releases! -# - name: FORCE AN UPGRADE IF calibre-installer.py HAS CHANGED, IF SO ORIGINAL IS SAVED TO {{ calibre_download_output.backup_file }} -# file: -# path: /usr/bin/calibre-uninstall -# state: absent -# when: calibre_download_output.backup_file is defined - -- name: Check if calibre-installer.py exists in /opt/iiab/downloads - stat: - path: "{{ downloads_dir }}/calibre-installer.py" - register: calib_inst - when: is_redhat - -- name: Check if calibre-uninstall exists in /usr/bin - stat: - path: "/usr/bin/calibre-uninstall" - register: calib_uninst - when: is_redhat - -#- name: FAIL (force Ansible to exit) IF /opt/iiab/downloads/calibre-installer.py doesn't exist OR needed Internet connection is missing -# meta: end_play -# fail: -# msg: "{{ downloads_dir }}/calibre-installer.py and an Internet connection are REQUIRED in order to install Calibre!" -# when: (not calib_inst.stat.exists) or (not internet_available and not calib_uninst.stat.exists) - -# INSTALL THE LATEST CALIBRE (calibre-server etc) ON ALL OS'S - RUNS IF /usr/bin/calibre-uninstall DOES NOT ALEADY EXIST - -- name: Run calibre-installer.py to install Calibre programs into /usr/bin - MANUALLY REMOVE /usr/bin/calibre-uninstall TO FORCE calibre-installer.py TO REINSTALL/UPGRADE HERE! - shell: "{{ downloads_dir }}/calibre-installer.py >> /dev/null" - args: - creates: /usr/bin/calibre-uninstall - when: internet_available and is_redhat - -- name: Install Calibre (OS's other than CentOS) - package: name={{ item }} - state=present - with_items: - - calibre - when: calibre_install and ansible_distribution != 'CentOS' - -- 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'} - -# 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: is_debuntu - -# CREATE CALIBRE DATABASE WITH A SAMPLE BOOK - -- name: Disable Calibre service -- stops calibre-server by Kovid Goyal - service: - name: calibre-serve - enabled: no - state: stopped - - name: Create /library/calibre (mandatory since Calibre 3.x) file: path: "{{ calibre_dbpath }}" @@ -107,11 +20,6 @@ path: "{{ content_base }}/downloads/{{ calibre_sample_book }}" register: sample_bk -- name: Check if /library/calibre/metadata.db exists - stat: - path: "{{ calibre_dbpath }}/metadata.db" - register: calibre_db - - name: Incorporate sample book into Calibre DB (mandatory since Calibre 3.x) shell: "calibredb add {{ content_base }}/downloads/{{ calibre_sample_book }} --with-library {{ calibre_dbpath }}" when: sample_bk.stat.exists and not calibre_db.stat.exists diff --git a/roles/calibre/tasks/installer.yml b/roles/calibre/tasks/installer.yml new file mode 100644 index 000000000..873f5463a --- /dev/null +++ b/roles/calibre/tasks/installer.yml @@ -0,0 +1,50 @@ +- name: Download latest linux-installer.py from GitHub to calibre-installer.py +# seems to work with just about any Linux, and deals with dependencies +# but is arch dependent + get_url: + url: "{{ calibre_src_url }}" + dest: "{{ downloads_dir }}/calibre-installer.py" + mode: 0755 + force: yes + backup: yes + register: calibre_download_output + when: internet_available + +# ALWAYS DEFINED, DESPITE get_url DOCUMENTATION CLAIM... +# - debug: +# msg: "{{ calibre_download_output.src }}" +# +# DEFINED ONLY WHEN /opt/iiab/downloads/calibre-installer.py CHANGES +# - debug: +# msg: "{{ calibre_download_output.backup_file }}" + +# OOPS BAD IDEA: changes in https://github.com/kovidgoyal/calibre/commits/master/setup/linux-installer.py are not sync'd with Calibre releases! +# - name: FORCE AN UPGRADE IF calibre-installer.py HAS CHANGED, IF SO ORIGINAL IS SAVED TO {{ calibre_download_output.backup_file }} +# file: +# path: /usr/bin/calibre-uninstall +# state: absent +# when: calibre_download_output.backup_file is defined + +- name: Check if calibre-installer.py exists in /opt/iiab/downloads + stat: + path: "{{ downloads_dir }}/calibre-installer.py" + register: calib_inst + +- name: Check if calibre-uninstall exists in /usr/bin + stat: + path: "/usr/bin/calibre-uninstall" + register: calib_uninst + +- name: FAIL (force Ansible to exit) IF /opt/iiab/downloads/calibre-installer.py doesn't exist OR needed Internet connection is missing + meta: end_play + fail: + msg: "{{ downloads_dir }}/calibre-installer.py and an Internet connection are REQUIRED in order to install Calibre!" + when: (not calib_inst.stat.exists) or (not internet_available and not calib_uninst.stat.exists) + +# INSTALL THE LATEST CALIBRE (calibre-server etc) ON ALL OS'S - RUNS IF /usr/bin/calibre-uninstall DOES NOT ALEADY EXIST + +- name: Run calibre-installer.py to install Calibre programs into /usr/bin - MANUALLY REMOVE /usr/bin/calibre-uninstall TO FORCE calibre-installer.py TO REINSTALL/UPGRADE HERE! + shell: "{{ downloads_dir }}/calibre-installer.py >> /dev/null" + args: + creates: /usr/bin/calibre-uninstall + when: internet_available diff --git a/roles/calibre/tasks/main.yml b/roles/calibre/tasks/main.yml index 02005883a..de6cec118 100644 --- a/roles/calibre/tasks/main.yml +++ b/roles/calibre/tasks/main.yml @@ -3,7 +3,15 @@ path: "{{ calibre_dbpath }}/metadata.db" register: calibre_db -- name: Install Calibre +- name: Installing Calibre via calibre-installer.py + include_tasks: installing.yml + when: not calibre_db.stat.exists and (is_redhat or is_ubuntu) + +- name: Install Calibre via .debs + include_tasks: debs.yml + when: not calibre_db.stat.exists and is_debian + +- name: Install Calibre - All include_tasks: install.yml when: not calibre_db.stat.exists