1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

Merge pull request #1968 from holta/kolibri-apt-not-pip

Install Kolibri w/ apt (.deb file) instead of pip (.pex file)
This commit is contained in:
A Holt 2019-09-30 00:44:09 -04:00 committed by GitHub
commit a0fb948ffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 104 additions and 121 deletions

View file

@ -8,9 +8,9 @@
mode: 0755
state: directory
with_items:
- "{{ iiab_zim_path }}"
- "{{ iiab_zim_path }}/content"
- "{{ iiab_zim_path }}/index"
- "{{ iiab_zim_path }}"
- "{{ iiab_zim_path }}/content"
- "{{ iiab_zim_path }}/index"
- name: Check for {{ kiwix_library_xml }} # /library/zims/library.xml
stat:
@ -19,14 +19,12 @@
- name: Install a stub /library/zims/library.xml if one doesn't exist
template:
src: "{{ item }}"
src: library.xml
dest: "{{ kiwix_library_xml }}"
mode: 0644
owner: root
group: root
force: no
with_items:
- library.xml
when: not kiwix_xml.stat.exists
- name: Check for /opt/iiab/kiwix/bin/kiwix-serve binary
@ -73,14 +71,15 @@
# 3. ENABLE MODS FOR APACHE PROXY IF DEBUNTU
# 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
- proxy
- proxy_html
- proxy_http
- rewrite
when: is_debuntu | bool
# 4. CREATE/ENABLE/RESTART (OR DISABLE) KIWIX SERVICE & ITS CRON JOB
@ -94,12 +93,10 @@
group: root
mode: "{{ item.mode }}"
with_items:
- { src: 'kiwix-serve.service.j2', dest: '/etc/systemd/system/kiwix-serve.service', mode: '0644'}
# - { src: 'kiwix-serve-init.j2', dest: '/usr/libexec/kiwix-serve-init', mode: '0755'}
- { src: 'iiab-make-kiwix-lib', dest: '/usr/bin/iiab-make-kiwix-lib', mode: '0755'}
- { src: 'iiab-make-kiwix-lib.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755'}
# - { src: 'iiab-make-apache-config.py', dest: '/usr/bin/iiab-make-apache-config.py', mode: '0755'}
- { src: 'kiwix.conf.j2', dest: '/etc/{{ apache_config_dir }}/kiwix.conf', mode: '0644'}
- { 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-lib.py', dest: '/usr/bin/iiab-make-kiwix-lib.py', mode: '0755'}
- { src: 'kiwix.conf.j2', dest: '/etc/{{ apache_config_dir }}/kiwix.conf', mode: '0644'}
- name: Create softlink kiwix.conf from sites-enabled to sites-available - for Kiwix Proxy in Apache - is disabled by turning off service kiwix-serve (debuntu)
file:
@ -157,19 +154,19 @@
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: name
value: Kiwix
- option: description
value: '"Part of https://github.com/kiwix/kiwix-tools/ - kiwix-serve is the most used web server for ZIM files."'
- option: kiwix_url
value: "{{ kiwix_url }}"
- option: kiwix_path
value: "{{ kiwix_path }}"
- option: kiwix_port
value: "{{ kiwix_port }}"
- option: iiab_zim_path
value: "{{ iiab_zim_path }}"
- option: kiwix_library_xml
value: "{{ kiwix_library_xml }}"
- option: kiwix_enabled
value: "{{ kiwix_enabled }}"
- option: name
value: Kiwix
- option: description
value: '"Part of https://github.com/kiwix/kiwix-tools/ - kiwix-serve is the most used web server for ZIM files."'
- option: kiwix_url
value: "{{ kiwix_url }}"
- option: kiwix_path
value: "{{ kiwix_path }}"
- option: kiwix_port
value: "{{ kiwix_port }}"
- option: iiab_zim_path
value: "{{ iiab_zim_path }}"
- option: kiwix_library_xml
value: "{{ kiwix_library_xml }}"
- option: kiwix_enabled
value: "{{ kiwix_enabled }}"

View file

@ -1,40 +0,0 @@
#!/usr/bin/python
# write out proxy definitions for zim currently loaded
import os, sys, syslog
iiab_zim_path = "{{ iiab_zim_path }}"
kiwix_apache_config = "/etc/{{ apache_config_dir }}/kiwix.conf"
def main ():
content = iiab_zim_path + "/content/"
index = iiab_zim_path + "/index/"
# remove existing file
try:
os.remove(kiwix_apache_config)
except:
pass
with open(kiwix_apache_config, 'w') as fp:
fp.write("RewriteEngine on\n")
fp.write("ProxyPreserveHost on\n")
fp.write("ProxyPass /kiwix http://127.0.0.1:3000\n")
fp.write("ProxyPassReverse /kiwix http://127.0.0.1:3000\n")
for filename in os.listdir(content):
zimpos = filename.find(".zim")
if zimpos != -1:
filename = filename[:zimpos]
fp.write("RewriteRule %s(.*) http://127.0.0.1:3000/%s$1 [P]\n"% (filename,filename))
fp.write("ProxyPassReverse %s$1 http://localhost:3000/%s$1\n" % (filename,filename))
if __name__ == "__main__":
# Run the main routine
main()
# vim: tabstop=3 shiftwidth=3 expandtab softtabstop=3

View file

@ -1,13 +1,22 @@
# kolibri_install: False
# kolibri_enabled: False
# kolibri_language: en # ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu
# kolibri_http_port: 8009
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
# 2019-06-21: Just comment out this pinning line if you want Kolibri's "latest" version, after 0.12.4's bug is resolved: https://github.com/iiab/iiab/issues/1675 https://github.com/learningequality/kolibri/issues/5664
# kolibri_version: 0.12.5
# 2019-09-27: Pinning to a particular version is unfortunately NOT supported
# with our new apt approach (.deb installer) at this time.
# 2019-06-21: Uncomment this pinning line if you want a particular version of
# Kolibri rather than the "latest", e.g. to work around after 0.12.4's bug:
# kolibri_version: 0.12.3
# https://github.com/iiab/iiab/issues/1675
# https://github.com/learningequality/kolibri/issues/5664
kolibri_deb_url: https://learningequality.org/r/kolibri-deb-latest
# Kolibri folder to store its data and configuration files.
kolibri_home: "{{ content_base }}/kolibri" # /library/kolibri
@ -15,26 +24,22 @@ kolibri_home: "{{ content_base }}/kolibri" # /library/kolibri
kolibri_url_without_slash: /kolibri
kolibri_url: "{{ kolibri_url_without_slash }}/" # /kolibri/
kolibri_venv_path: /usr/local/kolibri # For /usr/local/kolibri/bin/kolibri
# 2018-07-16: IIAB recommends /usr/bin but @arky says this isn't yet possible, due to pip
kolibri_exec_path: "{{ kolibri_venv_path }}/bin/kolibri"
kolibri_exec_path: /usr/bin/kolibri
# Kolibri system user
kolibri_user: kolibri
kolibri_user: kolibri # Whereas a vanilla install of Kolibri auto-identifies
# and saves a 'desktop' user like {iiab-admin, pi} to /etc/kolibri/username,
# towards guaranteeing access to USB devices, per:
# https://kolibri.readthedocs.io/en/latest/install.html#changing-the-owner-of-kolibri-system-service
# Kolibri setup will be provisioned with default administration account, preset and
# language. You could turn this to 'False' while reinstalling kolibri.
# To populate /library/kolibri with essential/minimum files and dirs. This
# provisions Kolibri with facility name, admin acnt / password, preset type,
# and language. You can set this to 'False' when reinstalling Kolibri:
kolibri_provision: True
# Kolibri Facility name
kolibri_facility: Kolibri-in-a-Box
kolibri_admin_user: Admin
kolibri_admin_password: changeme
# Kolibri Preset type: formal, nonformal, informal
kolibri_preset: formal
# Kolibri default language (ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu)
kolibri_language: en
# Kolibri admin account
kolibri_admin_user: Admin
kolibri_admin_password: changeme

View file

@ -1,4 +1,4 @@
- name: Create Linux user {{ kolibri_user }} and add it to groups {{ apache_user }}, disk
- name: Create Linux user '{{ kolibri_user }}' and add it to groups '{{ apache_user }}', 'disk'
user:
name: "{{ kolibri_user }}"
groups:
@ -9,34 +9,37 @@
system: yes
create_home: no
- name: Create {{ kolibri_home }} (for data) and {{ kolibri_venv_path }} (venv for program/config)
- name: Create {{ kolibri_home }} (for Kolibri content, configuration, sqlite3 databases)
file:
path: "{{ item }}"
owner: "{{ kolibri_user }}"
group: "{{ apache_user }}"
path: "{{ kolibri_home }}" # /library/kolibri
owner: "{{ kolibri_user }}" # kolibri
group: "{{ apache_user }}" # www-data (on Debian/Ubuntu/Raspbian)
mode: 0755
state: directory
with_items:
- "{{ kolibri_home }}" # /library/kolibri
- "{{ kolibri_venv_path }}" # /usr/local/kolibri
- name: Install latest Kolibri using pip, to venv
pip:
name: kolibri
virtualenv: "{{ kolibri_venv_path }}"
virtualenv_site_packages: no
state: latest
extra_args: --no-cache-dir
when: internet_available and not (kolibri_version is defined)
- name: Create /etc/kolibri
file:
name: /etc/kolibri
state: directory
owner: root
group: root
mode: 0755
- name: Install Kolibri {{ kolibri_version }} using pip, to venv
pip:
name: kolibri
virtualenv: "{{ kolibri_venv_path }}"
virtualenv_site_packages: no
version: "{{ kolibri_version }}"
extra_args: --no-cache-dir
when: internet_available and kolibri_version is defined
- name: Save kolibri_user ({{ kolibri_user }}) to /etc/kolibri/username
copy:
content: "{{ kolibri_user }}"
dest: /etc/kolibri/username
owner: root
group: root
mode: 0644
- name: apt install latest Kolibri .deb from {{ kolibri_deb_url }}
apt:
deb: "{{ kolibri_deb_url }}" # https://learningequality.org/r/kolibri-deb-latest
environment:
KOLIBRI_HOME: "{{ kolibri_home }}" # these don't do a thing for now but
KOLIBRI_USER: "{{ kolibri_user }}" # both can't hurt & Might Help Later
when: internet_available | bool
- name: 'Install from templates: kolibri.service unit file for systemd & sites-available/kolibri.conf for Apache'
template:
@ -56,33 +59,47 @@
enabled: yes
state: stopped
- name: Run Kolibri migrations (WHY? WHAT DOES THIS DO?)
- name: Run Kolibri migrations to begin populating {{ kolibri_home }} # i.e. /library/kolibri
shell: export KOLIBRI_HOME="{{ kolibri_home }}" && "{{ kolibri_exec_path }}" manage migrate
ignore_errors: yes
become: yes
become_user: "{{ kolibri_user }}"
when: kolibri_provision | bool
- name: Set Kolibri default language
shell: export KOLIBRI_HOME="{{ kolibri_home }}" && "{{ kolibri_exec_path }}" language setdefault "{{ kolibri_language }}"
ignore_errors: yes
become: yes
become_user: "{{ kolibri_user }}"
when: kolibri_provision | bool
- name: Create Kolibri default facility name, admin account and language
- name: Set Kolibri facility name, admin acnt / password, preset type, and language
shell: >
export KOLIBRI_HOME="{{ kolibri_home }}" &&
"{{ kolibri_exec_path }}" manage provisiondevice --facility "{{ kolibri_facility }}"
--superusername "{{ kolibri_admin_user }}" --superuserpassword "{{ kolibri_admin_password }}"
--preset "{{ kolibri_preset }}" --language_id "{{ kolibri_language }}" --verbosity 0 --noinput
ignore_errors: yes
become: yes
become_user: "{{ kolibri_user }}"
when: kolibri_provision | bool
- name: chown -R {{ kolibri_user }}:{{ apache_user }} {{ kolibri_home }}
- name: chown -R {{ kolibri_user }}:{{ apache_user }} {{ kolibri_home }} for good measure?
file:
path: "{{ kolibri_home }}"
owner: "{{ kolibri_user }}"
group: "{{ apache_user }}"
path: "{{ kolibri_home }}" # /library/kolibri
owner: "{{ kolibri_user }}" # kolibri
group: "{{ apache_user }}" # www-data (on Debian/Ubuntu/Raspbian)
recurse: yes
when: kolibri_provision | bool
# 2019-09-29: roles/kiwix/tasks/kiwix_install.yml installs 4 Apache modules
# for similar purposes (not all nec?) Only 1 (proxy_http) is needed here.
- name: Enable Apache module proxy_http for http://box{{ kolibri_url }} # i.e. http://box/kolibri
apache2_module:
name: proxy_http
- name: Start 'kolibri' systemd service, if kolibri_enabled
systemd:
name: kolibri
@ -122,9 +139,9 @@
value: '"Kolibri is an open-source educational platform specially designed to provide offline access to a wide range of quality, openly licensed educational contents in low-resource contexts like rural schools, refugee camps, orphanages, and also in non-formal school programs."'
- option: kolibri_url
value: "{{ kolibri_url }}"
- option: kolibri_path
- option: kolibri_exec_path
value: "{{ kolibri_exec_path }}"
- option: kolibri_port
- option: kolibri_http_port
value: "{{ kolibri_http_port }}"
- option: kolibri_enabled
value: "{{ kolibri_enabled }}"

View file

@ -387,6 +387,7 @@ kalite_password: kalite
kolibri_install: False
kolibri_enabled: False
kolibri_language: en # ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu
kolibri_http_port: 8009
# kiwix_install: True is REQUIRED, if you install IIAB's Admin Console

View file

@ -262,6 +262,7 @@ kalite_cron_enabled: True
kolibri_install: True
kolibri_enabled: True
kolibri_language: en # ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu
# kiwix_install: True is REQUIRED, if you install IIAB's Admin Console
kiwix_install: True

View file

@ -259,6 +259,7 @@ kalite_cron_enabled: True
kolibri_install: False
kolibri_enabled: False
kolibri_language: en # ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu
# kiwix_install: True is REQUIRED, if you install IIAB's Admin Console
kiwix_install: True

View file

@ -259,6 +259,7 @@ kalite_cron_enabled: True
kolibri_install: False
kolibri_enabled: False
kolibri_language: en # ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu
# kiwix_install: True is REQUIRED, if you install IIAB's Admin Console
kiwix_install: True