2020-02-14 01:31:34 +00:00
# 0. SET CPU ARCHITECTURE
2020-01-11 17:38:37 +00:00
2020-02-14 01:31:34 +00:00
- name : "Initialize 'kiwix_src_dir: False' just in case CPU architecture is not supported"
set_fact :
kiwix_src_dir : False
2021-06-04 00:56:17 +00:00
- name : "Set fact 'kiwix_src_dir: {{ kiwix_version_armhf }}' (armv6l or armv71 or aarch64)"
2020-02-14 01:31:34 +00:00
set_fact :
kiwix_src_dir : "{{ kiwix_version_armhf }}"
2021-06-04 00:56:17 +00:00
when : ansible_machine == "armv6l" or ansible_machine == "armv7l" or ansible_machine == "aarch64"
2020-02-14 01:31:34 +00:00
- name : "Set fact 'kiwix_src_dir: {{ kiwix_version_linux64 }}' (x86_64)"
set_fact :
kiwix_src_dir : "{{ kiwix_version_linux64 }}"
when : ansible_machine == "x86_64"
- name : "Set fact 'kiwix_src_dir: {{ kiwix_version_i686 }}' (i686)"
set_fact :
kiwix_src_dir : "{{ kiwix_version_i686 }}"
when : ansible_machine == "i686"
# COMMENT OUT LINE ABOVE TO TEST i686 CODE PATH ON X86_64 (WORKS NOV 2017)
- name : Force Ansible to exit (FAIL) if kiwix-tools appears unavailable for your architecture ({{ ansible_machine }})
fail :
msg : "WARNING: kiwix-tools SOFTWARE APPEARS UNAVAILABLE FOR YOUR {{ ansible_machine }} OS/ARCHITECTURE."
when : not kiwix_src_dir
- name : "Set fact 'kiwix_src_file: {{ kiwix_src_dir }}.tar.gz'"
set_fact :
kiwix_src_file : "{{ kiwix_src_dir }}.tar.gz"
2020-11-09 11:33:36 +00:00
# 1. PUT IN PLACE: /opt/iiab/downloads/kiwix-tools_linux-*.tar.gz, essential dirs, and test.zim if nec (library.xml is created later, by enable-or-disable.yml)
2020-02-14 01:31:34 +00:00
- name : Download {{ iiab_download_url }}/{{ kiwix_src_file }} to /opt/iiab/downloads
2019-10-16 05:39:27 +00:00
get_url :
2020-02-14 01:31:34 +00:00
url : "{{ iiab_download_url }}/{{ kiwix_src_file }}" # http://download.iiab.io/packages
2020-11-09 11:20:57 +00:00
dest : "{{ downloads_dir }}/{{ kiwix_src_file }}" # /opt/iiab/downloads
2019-10-16 05:39:27 +00:00
timeout : "{{ download_timeout }}"
2020-10-16 20:46:19 +00:00
when : internet_available
2019-10-16 05:39:27 +00:00
2020-11-09 11:20:57 +00:00
- name : "Create dirs, including parent dirs: {{ kiwix_path }}/bin (executables), {{ iiab_zim_path }}/content (ZIM files), {{ iiab_zim_path }}/index (legacy indexes)"
2017-11-25 22:12:26 +00:00
file :
path : "{{ item }}"
state : directory
2017-05-27 18:09:50 +00:00
with_items :
2020-11-09 11:20:57 +00:00
- "{{ kiwix_path }}/bin" # /opt/iiab/kiwix
- "{{ iiab_zim_path }}/content" # /library/zims
2019-09-30 03:03:59 +00:00
- "{{ iiab_zim_path }}/index"
2017-05-27 18:09:50 +00:00
2020-11-09 11:20:57 +00:00
- name : Count *.zim files in {{ iiab_zim_path }}/content
find :
paths : "{{ iiab_zim_path }}/content"
patterns : '*.zim'
2020-11-08 19:30:31 +00:00
register : kiwix_zims
2017-09-11 16:21:07 +00:00
2020-11-09 11:20:57 +00:00
- name : If there were none, install {{ iiab_zim_path }}/content/test.zim
2017-11-25 22:12:26 +00:00
copy :
src : test.zim
2017-11-27 03:33:05 +00:00
dest : "{{ iiab_zim_path }}/content/test.zim"
2020-11-09 11:20:57 +00:00
#force: no
when : kiwix_zims.matched == 0
2017-05-27 18:09:50 +00:00
2020-01-30 09:00:00 +00:00
2020-01-11 17:38:37 +00:00
# 2. INSTALL KIWIX-TOOLS EXECUTABLES
2017-11-26 16:58:58 +00:00
2020-11-09 11:20:57 +00:00
- name : Unarchive {{ kiwix_src_file }} to /tmp # e.g. kiwix-tools_linux-armhf-3.1.2-3.tar.gz
2017-11-27 03:33:05 +00:00
unarchive :
src : "{{ downloads_dir }}/{{ kiwix_src_file }}"
dest : /tmp
2018-03-27 15:48:56 +00:00
2020-02-14 01:31:34 +00:00
- name : Move /tmp/{{ kiwix_src_dir }}/* to permanent location {{ kiwix_path }}/bin
shell : "mv /tmp/{{ kiwix_src_dir }}/* {{ kiwix_path }}/bin/" # /opt/iiab/kiwix
2017-11-27 03:33:05 +00:00
2020-01-30 09:00:00 +00:00
2017-11-27 03:33:05 +00:00
# 3. ENABLE MODS FOR APACHE PROXY IF DEBUNTU
2017-11-26 16:58:58 +00:00
2019-10-07 18:37:17 +00:00
# 2019-10-07: Moved to roles/httpd/tasks/main.yml
2019-09-30 07:02:22 +00:00
# 2019-09-29: Compare roles/kolibri/defaults/main.yml using just 1 (proxy_http)
2019-10-07 18:37:17 +00:00
#- name: Enable the 4 mods which permit Apache to proxy (debuntu)
# apache2_module:
# name: "{{ item }}"
# with_items:
# - proxy
# - proxy_html
# - proxy_http
# - rewrite
2020-10-16 20:46:19 +00:00
# when: is_debuntu
2017-11-26 15:38:48 +00:00
2020-01-30 09:00:00 +00:00
2020-01-11 17:38:37 +00:00
# 4. INSTALL iiab-make-kiwix-lib*, kiwix-serve.service, kiwix.conf for Apache
2017-05-27 18:09:50 +00:00
2020-05-17 02:48:52 +00:00
- name: 'Install from templates : kiwix-serve.service, iiab-make-kiwix-lib, iiab-make-kiwix-lib.py'
2017-11-25 22:12:26 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items :
2020-01-12 00:09:29 +00:00
- { src: 'kiwix-serve.service.j2', dest: '/etc/systemd/system/kiwix-serve.service', mode : '0644' }
- { src: 'iiab-make-kiwix-lib', dest: '/usr/bin/iiab-make-kiwix-lib', mode : '0755' }
- { src: 'iiab-make-kiwix-lib3.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode : '0755' }
2020-05-17 02:48:52 +00:00
2020-11-09 11:59:26 +00:00
- name : daemon_reload, so systemd (re)reads newly installed kiwix-serve.service
2020-11-08 13:31:09 +00:00
systemd :
daemon_reload : yes
2020-11-09 11:20:57 +00:00
- name : "Install from template: /etc/{{ apache_conf_dir }}/kiwix.conf"
2020-05-17 02:48:52 +00:00
template :
src : kiwix.conf.j2
2020-11-09 11:20:57 +00:00
dest : "/etc/{{ apache_conf_dir }}/kiwix.conf" # apache2/sites-available
2020-05-17 02:48:52 +00:00
#mode: '0644'
when : apache_installed is defined
2020-01-30 09:00:00 +00:00
2020-07-15 20:05:19 +00:00
# install kiwix app
2020-07-15 20:25:37 +00:00
- name : Install Kiwix Android app
include_tasks : kiwix-apk.yml
2020-07-15 20:05:19 +00:00
when : kiwix_incl_apk
2020-01-30 09:00:00 +00:00
2020-11-09 11:20:57 +00:00
2020-01-30 09:00:00 +00:00
# 5. RECORD Kiwix AS INSTALLED
2017-12-02 16:49:25 +00:00
2020-01-30 09:00:00 +00:00
- name : "Set 'kiwix_installed: True'"
set_fact :
kiwix_installed : True
2020-01-11 17:38:37 +00:00
2020-01-12 23:15:33 +00:00
- name : "Add 'kiwix_installed: True' to {{ iiab_state_file }}"
2019-09-09 17:14:13 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-09-09 17:14:13 +00:00
regexp : '^kiwix_installed'
2019-10-07 17:11:21 +00:00
line: 'kiwix_installed : True '