mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 19:52:06 +00:00
125 lines
4.1 KiB
YAML
125 lines
4.1 KiB
YAML
# 0. SET CPU ARCHITECTURE
|
|
|
|
- name: "Initialize 'kiwix_src_dir: False' just in case CPU architecture is not supported"
|
|
set_fact:
|
|
kiwix_src_dir: False
|
|
|
|
- name: "Set fact 'kiwix_src_dir: {{ kiwix_version_armhf }}' (armv6l or armv71)"
|
|
set_fact:
|
|
kiwix_src_dir: "{{ kiwix_version_armhf }}"
|
|
when: ansible_machine == "armv7l" or ansible_machine == "armv6l" or ansible_machine == "aarch64"
|
|
|
|
- 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"
|
|
|
|
|
|
# 1. PUT IN PLACE: ESSENTIAL DIRS, library.xml, test.zim
|
|
|
|
- name: Download {{ iiab_download_url }}/{{ kiwix_src_file }} to /opt/iiab/downloads
|
|
get_url:
|
|
url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" # http://download.iiab.io/packages
|
|
dest: "{{ downloads_dir }}/{{ kiwix_src_file }}"
|
|
timeout: "{{ download_timeout }}"
|
|
when: internet_available | bool
|
|
|
|
- name: Create dir {{ iiab_zim_path }} and subdirs {content, index} for Kiwix ZIM files
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "{{ iiab_zim_path }}" # /library/zims
|
|
- "{{ iiab_zim_path }}/content"
|
|
- "{{ iiab_zim_path }}/index"
|
|
|
|
- name: Check for {{ kiwix_library_xml }}
|
|
stat:
|
|
path: "{{ kiwix_library_xml }}" # /library/zims/library.xml
|
|
register: kiwix_xml
|
|
|
|
- name: Install stub /library/zims/library.xml from template, if one doesn't exist
|
|
template:
|
|
src: library.xml
|
|
dest: "{{ kiwix_library_xml }}"
|
|
force: no
|
|
when: not kiwix_xml.stat.exists
|
|
|
|
- name: Install {{ iiab_zim_path }}/content/test.zim
|
|
copy:
|
|
src: test.zim
|
|
dest: "{{ iiab_zim_path }}/content/test.zim"
|
|
force: no
|
|
|
|
- name: Create {{ kiwix_path }}/bin directory
|
|
file:
|
|
path: "{{ kiwix_path }}/bin" # /opt/iiab/kiwix
|
|
state: directory
|
|
|
|
|
|
# 2. INSTALL KIWIX-TOOLS EXECUTABLES
|
|
|
|
- name: Unarchive {{ kiwix_src_file }} to /tmp # e.g. kiwix-tools_linux-armhf-0.6.1-1.tar.gz
|
|
unarchive:
|
|
src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
|
|
dest: /tmp
|
|
|
|
- name: Move /tmp/{{ kiwix_src_dir }}/* to permanent location {{ kiwix_path }}/bin
|
|
shell: "mv /tmp/{{ kiwix_src_dir }}/* {{ kiwix_path }}/bin/" # /opt/iiab/kiwix
|
|
|
|
|
|
# 3. ENABLE MODS FOR APACHE PROXY IF DEBUNTU
|
|
|
|
# 2019-10-07: Moved to roles/httpd/tasks/main.yml
|
|
# 2019-09-29: Compare roles/kolibri/defaults/main.yml using just 1 (proxy_http)
|
|
#- name: Enable the 4 mods which permit Apache to proxy (debuntu)
|
|
# apache2_module:
|
|
# name: "{{ item }}"
|
|
# with_items:
|
|
# - proxy
|
|
# - proxy_html
|
|
# - proxy_http
|
|
# - rewrite
|
|
# when: is_debuntu | bool
|
|
|
|
|
|
# 4. INSTALL iiab-make-kiwix-lib*, kiwix-serve.service, kiwix.conf for Apache
|
|
|
|
- name: 'Install from templates: kiwix-serve.service, iiab-make-kiwix-lib, iiab-make-kiwix-lib.py, kiwix.conf'
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
mode: "{{ item.mode }}"
|
|
with_items:
|
|
- { 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' }
|
|
- { src: 'kiwix.conf.j2', dest: '/etc/{{ apache_conf_dir }}/kiwix.conf', mode: '0644' }
|
|
|
|
|
|
# 5. RECORD Kiwix AS INSTALLED
|
|
|
|
- name: "Set 'kiwix_installed: True'"
|
|
set_fact:
|
|
kiwix_installed: True
|
|
|
|
- name: "Add 'kiwix_installed: True' to {{ iiab_state_file }}"
|
|
lineinfile:
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
regexp: '^kiwix_installed'
|
|
line: 'kiwix_installed: True'
|