From 8ea20d9b6812d63d3e39052fba367941c154be2e Mon Sep 17 00:00:00 2001 From: Arky Date: Mon, 16 Jul 2018 00:36:05 +0700 Subject: [PATCH] Kolibri role Add Kolibri role for IIAB 6.6 Preview --- roles/kolibri/README.rst | 65 +++++++++++++++ roles/kolibri/defaults/main.yml | 34 ++++++++ roles/kolibri/tasks/main.yml | 97 ++++++++++++++++++++++ roles/kolibri/templates/kolibri.service.j2 | 16 ++++ 4 files changed, 212 insertions(+) create mode 100644 roles/kolibri/README.rst create mode 100644 roles/kolibri/defaults/main.yml create mode 100644 roles/kolibri/tasks/main.yml create mode 100644 roles/kolibri/templates/kolibri.service.j2 diff --git a/roles/kolibri/README.rst b/roles/kolibri/README.rst new file mode 100644 index 000000000..eb0b5d4ee --- /dev/null +++ b/roles/kolibri/README.rst @@ -0,0 +1,65 @@ +============== +Kolibri README +============== + +This role install Kolibri, 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. + +Access +------ + +If enabled and with the default settings Kolibri should be accessible at http://box:8009/ + +To login to Kolibri enter + + User Name: Admin + + Password: changeme + +Configuration Parameters +------------------------ + +Please look in defaults/main.yml for the default values of the various install parameters. Everything +in this readme assumes the default values. + +Automatic Device Provisioning +----------------------------- +When kolibri_provision is enabled, the installation will setup the following settings: + + Kolibri Facility name: 'Kolibri-in-a-Box' + + Kolibri Preset type: formal (Other options are nonformal, informal) + + Kolibri default language: en (Otherwise language are ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu) + + Kolibri Admin User: Admin + + Kolibri Admin password: changeme + +Cloning content +--------------- +In Kolibri 0.10 introduced `kolibri manage deprovision` which will remove +user configuration, leaving content intact. You can then copy/clone /library/kolibri +to a new location. + + +Trouble Shooting +---------------- + +You can run the server manually with the following commands: + + systemctl stop kolibri (make sure the systemd service is not running) + + export KOLIBRI_HOME=/library/kolibri + + export KOLIBRI_HTTP_PORT=8009 (other Kolibri will run on default port 8080) + + kolibri start + +To return to using the systemd unit: + + kolibri stop + + systemctl start kolibri diff --git a/roles/kolibri/defaults/main.yml b/roles/kolibri/defaults/main.yml new file mode 100644 index 000000000..769604cd1 --- /dev/null +++ b/roles/kolibri/defaults/main.yml @@ -0,0 +1,34 @@ +# The values here are defaults. +# To override them edit the main var definitions in iiab/vars + +# Installation Variables +kolibri_install: True +kolibri_enabled: True + +# Kolibri folder to store its data and configuration files. +kolibri_home: "{{ content_base }}/kolibri" + +kolibri_http_port: 8009 +kolibri_url: /kolibri/ +kolibri_path: "{{ iiab_base }}/kolibri" +kolibri_exec_path: /usr/local/bin/kolibri + +# Kolibri system user +kolibri_user: kolibri + +# Kolibri setup will be provisioned with default administration account, preset and +# language. You could turn this to 'False' while reinstalling kolibri. +kolibri_provision: True + +# Kolibri Facility name +kolibri_facility: 'Kolibri-in-a-Box' + +# 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' diff --git a/roles/kolibri/tasks/main.yml b/roles/kolibri/tasks/main.yml new file mode 100644 index 000000000..89ce010d6 --- /dev/null +++ b/roles/kolibri/tasks/main.yml @@ -0,0 +1,97 @@ +--- +- name: Create a Kolibri system user and to www-data, disk groups + user: + name: "{{ kolibri_user }}" + groups: + - "{{ apache_user }}" + - disk + state: present + shell: /bin/false + system: yes + create_home: no + +- name: Create Kolibri folder to store data and configuration files. + file: + path: "{{ item }}" + owner: "{{ kolibri_user }}" + group: "{{ apache_user }}" + mode: 0755 + state: directory + with_items: + - "{{ kolibri_home }}" + + +- name: Install kolibri using pip on all OS's + pip: + name: kolibri + state: latest + when: internet_available + +- name: Create kolibri systemd service file + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: "{{ item.mode }}" + owner: root + group: root + with_items: + - { src: 'kolibri.service.j2' , dest: '/etc/systemd/system/kolibri.service', mode: '0644' } + +- name: Set kolibri default language. + shell: export KOLIBRI_HOME="{{ kolibri_home }}" && "{{ kolibri_exec_path }}" language setdefault "{{ kolibri_language }}" + ignore_errors: yes + when: kolibri_provision + +- name: Create kolibri default facility name, admin account 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 + when: kolibri_provision + +- name: Change /library/kolibri directory permissions. + file: + path: "{{ kolibri_home }}" + owner: "{{ kolibri_user }}" + group: "{{ apache_user }}" + recurse: yes + +- name: Enable kolibri service. + service: + name: "{{ item.name }}" + enabled: yes + state: restarted + with_items: + - { name: kolibri } + when: kolibri_enabled + +- name: Disable kolibri service. + service: + name: "{{ item.name }}" + enabled: no + state: stopped + with_items: + - { name: kolibri } + when: not kolibri_enabled + +- name: Add 'kolibri' to list of services at /etc/iiab/iiab.ini + ini_file: + dest: "{{ service_filelist }}" + section: kolibri + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: kolibri + - option: description + 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 + value: "{{ kolibri_path }}" + - option: kolibri_port + value: "{{ kolibri_http_port }}" + - option: enabled + value: "{{ kolibri_enabled }}" diff --git a/roles/kolibri/templates/kolibri.service.j2 b/roles/kolibri/templates/kolibri.service.j2 new file mode 100644 index 000000000..ef420c4a1 --- /dev/null +++ b/roles/kolibri/templates/kolibri.service.j2 @@ -0,0 +1,16 @@ +[Unit] +Description=Kolibri + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=KOLIBRI_USER={{ kolibri_user }} +Environment=KOLIBRI_HOME={{ kolibri_home }} +Environment=KOLIBRI_HTTP_PORT={{ kolibri_http_port }} +User={{ kolibri_user }} +Group={{ apache_user }} +ExecStart={{ kolibri_exec_path }} start +ExecStop={{ kolibri_exec_path }} stop + +[Install] +WantedBy=multi-user.target