mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 03:32:12 +00:00
"desktop user’s account is preferred" required to avoid errors like "You are running this command as the user 'kolibri', but Kolibri was originally installed to run as the user 'pi'." As recommended by https://kolibri.readthedocs.io/en/latest/install.html#changing-the-owner-of-kolibri-system-service
158 lines
5.7 KiB
YAML
158 lines
5.7 KiB
YAML
- name: Create Linux user {{ kolibri_user }} and add it to groups {{ apache_user }}, disk
|
|
user:
|
|
name: "{{ kolibri_user }}"
|
|
groups:
|
|
- "{{ apache_user }}"
|
|
- disk
|
|
state: present
|
|
shell: /bin/false
|
|
system: yes
|
|
create_home: no
|
|
|
|
#- name: Create {{ kolibri_home }} (for data) and {{ kolibri_venv_path }} (venv for program/config)
|
|
- name: Create {{ kolibri_home }} (for data)
|
|
file:
|
|
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: Download latest Kolibri .deb installer from {{ kolibri_deb_url }}
|
|
# get_url:
|
|
# name: "{{ kolibri_deb_url }}" # https://learningequality.org/r/kolibri-deb-latest
|
|
# dest: "{{ downloads_dir }}"
|
|
# timeout: "{{ download_timeout }}"
|
|
# register: kolibri_download_output
|
|
# when: internet_available | bool
|
|
|
|
- name: apt install latest Kolibri .deb from {{ kolibri_deb_url }}
|
|
apt:
|
|
deb: "{{ kolibri_deb_url }}" # https://learningequality.org/r/kolibri-deb-latest
|
|
# "Requires the xz-utils package to extract the control file of the deb package to install."
|
|
when: internet_available | bool
|
|
#when: kolibri_download_output.dest is defined and (kolibri_version is undefined)
|
|
|
|
#- name: Install Kolibri {{ kolibri_version }} using apt
|
|
# apt:
|
|
# #update_cache: yes
|
|
# name: "kolibri={{ kolibri_version }}"
|
|
# when: kolibri_download_output.dest is defined and kolibri_version is defined
|
|
|
|
#- 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 (kolibri_version is undefined)
|
|
|
|
#- 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: 'Install from templates: kolibri.service unit file for systemd & sites-available/kolibri.conf for Apache'
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
with_items:
|
|
- { src: 'kolibri.service.j2', dest: '/etc/systemd/system/kolibri.service' }
|
|
- { src: 'kolibri.conf.j2', dest: '/etc/apache2/sites-available/kolibri.conf' }
|
|
|
|
- name: Enable 'kolibri' systemd service (for reboots) but ensure it's stopped for Kolibri provisioning
|
|
systemd:
|
|
name: kolibri
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
state: stopped
|
|
|
|
- name: Run Kolibri migrations (WHY? WHAT DOES THIS DO?)
|
|
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
|
|
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 }}
|
|
file:
|
|
path: "{{ kolibri_home }}" # /library/kolibri
|
|
owner: "{{ kolibri_user }}" # kolibri
|
|
group: "{{ apache_user }}" # www-data (on Debian/Ubuntu/Raspbian)
|
|
recurse: yes
|
|
when: kolibri_provision | bool
|
|
|
|
- name: Start 'kolibri' systemd service, if kolibri_enabled
|
|
systemd:
|
|
name: kolibri
|
|
state: started
|
|
when: kolibri_enabled | bool
|
|
|
|
- name: Enable http://box{{ kolibri_url }} with Apache (a2ensite) if kolibri_enabled # i.e. http://box/kolibri
|
|
command: a2ensite kolibri.conf
|
|
when: kolibri_enabled | bool
|
|
|
|
- name: Disable & Stop 'kolibri' systemd service if not kolibri_enabled
|
|
systemd:
|
|
name: kolibri
|
|
enabled: no
|
|
state: stopped
|
|
when: not kolibri_enabled
|
|
|
|
- name: Disable http://box{{ kolibri_url }} with Apache (a2dissite) if not kolibri_enabled
|
|
command: a2dissite kolibri.conf
|
|
when: not kolibri_enabled
|
|
|
|
- name: Restart Apache service ({{ apache_service }}) # e.g. apache2
|
|
systemd:
|
|
name: "{{ apache_service }}"
|
|
state: restarted
|
|
|
|
- name: Add 'kolibri' variable values to {{ iiab_ini_file }} # /etc/iiab/iiab.ini
|
|
ini_file:
|
|
path: "{{ iiab_ini_file }}"
|
|
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_exec_path }}"
|
|
- option: kolibri_port
|
|
value: "{{ kolibri_http_port }}"
|
|
- option: kolibri_enabled
|
|
value: "{{ kolibri_enabled }}"
|