2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2019-10-20 21:31:09 +00:00
- name : Download {{ kalite_requirements }} to {{ pip_packages_dir }}/kalite.txt
2017-12-08 06:33:31 +00:00
get_url :
url : "{{ kalite_requirements }}"
2019-10-20 21:04:56 +00:00
dest : "{{ pip_packages_dir }}/kalite.txt" # /opt/iiab/pip-packages/kalite.txt
2017-12-08 06:33:31 +00:00
timeout : "{{ download_timeout }}"
2017-09-17 18:07:34 +00:00
2021-03-08 13:36:51 +00:00
# 2020-01-19: https://github.com/piwheels/packages/issues/74 says the following is no longer needed...
2020-01-19 14:08:02 +00:00
#- name: Run 'mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139' as "TEMPORARY" workaround (2020-01-17) for piwheels.org's setuptools Python 2/3 brokenness on RPi (https://github.com/iiab/iiab/issues/2139)
# command: mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139
# ignore_errors: yes
2020-10-16 20:46:19 +00:00
# when: is_raspbian
2020-01-17 16:23:47 +00:00
2024-03-07 07:03:29 +00:00
- name: 'Install packages : python2, python-setuptools, virtualenv (for Python 2) -- if Ubuntu 22.04 / Mint 21'
2020-03-27 06:23:30 +00:00
package :
2020-04-02 12:44:21 +00:00
name :
2021-03-07 20:34:04 +00:00
- python2
2021-07-29 15:37:07 +00:00
- python-setuptools # Provides setuptools-44 on recent OS's (last version compatible with python2)
2023-03-18 02:53:22 +00:00
- virtualenv # Drags in 'python3-virtualenv' which in turn drags in 'python3-pip' -- for Ansible module 'pip' when used with 'virtualenv_command: /usr/bin/virtualenv' and 'virtualenv_python : python2.7' -- compare package 'python3-venv' used by roles {calibre-web, jupyterhub, lokole}
2020-03-19 10:45:26 +00:00
state : present
2024-03-07 07:03:29 +00:00
when : is_ubuntu_2204 # Also covers is_linuxmint_21
2020-03-19 10:45:26 +00:00
2024-03-07 07:03:29 +00:00
- name : Run scripts/install_python2.sh to install python2 and virtualenv -- if Debian 12 or RasPiOS 12
2023-04-05 18:02:43 +00:00
command : "{{ iiab_dir }}/scripts/install_python2.sh"
2024-03-07 07:03:29 +00:00
when : is_debian_12 # Also covers is_raspbian_12
2023-04-05 18:02:43 +00:00
2024-03-07 07:03:29 +00:00
- name : Use pip to pin setuptools to 44 in {{ kalite_venv }} -- if Ubuntu 22.04 / Mint 21, Ubuntu 23.10, Debian 12 or RasPiOS 12
2020-03-31 15:12:52 +00:00
pip :
2021-03-07 20:34:04 +00:00
name : setuptools==44
2020-03-31 15:12:52 +00:00
virtualenv : "{{ kalite_venv }}" # /usr/local/kalite/venv
virtualenv_site_packages : no
2023-05-19 19:45:38 +00:00
virtualenv_command : virtualenv # Traditionally /usr/bin/virtual/env -- but install_python2.sh (for Ubuntu 23.10+) sets up /usr/local/bin/virtualenv
2020-03-31 15:12:52 +00:00
virtualenv_python : python2.7
extra_args : "--no-use-pep517 --no-cache-dir --no-python-version-warning"
2024-03-07 07:03:29 +00:00
when : is_ubuntu_2204 or is_ubuntu_2310 or is_debian_12 # Also covers is_linuxmint_21 and is_raspbian_12
2020-03-31 15:12:52 +00:00
2024-03-07 07:03:29 +00:00
- name : Use pip to install ka-lite-static to {{ kalite_venv }} -- if Ubuntu 22.04 / Mint 21, Ubuntu 23.10, Debian 12 or RasPiOS 12
2017-12-08 06:33:31 +00:00
pip :
name : ka-lite-static
version : "{{ kalite_version }}"
2021-07-19 15:01:31 +00:00
virtualenv : "{{ kalite_venv }}"
2017-12-08 06:33:31 +00:00
virtualenv_site_packages : no
2023-05-19 19:45:38 +00:00
virtualenv_command : virtualenv
2019-10-31 14:11:30 +00:00
virtualenv_python : python2.7
2017-12-08 06:33:31 +00:00
extra_args : "--no-cache-dir"
2024-03-07 07:03:29 +00:00
when : is_ubuntu_2204 or is_ubuntu_2310 or is_debian_12 # Also covers is_linuxmint_21 and is_raspbian_12
2024-03-04 06:55:09 +00:00
2024-05-01 01:02:25 +00:00
# 2024-04-30: Sadly no longer works with Ubuntu 24.04 LTS final release (#3731).
# So roles/kalite is OS-restricted during initial install, SEE: roles/7-edu-apps/tasks/main.yml
# CLARIF: If install_python2_kalite-venv_u2404.sh proves no longer useful, it will deprecated in coming months.
2024-03-07 07:03:29 +00:00
- name : Run scripts/install_python2_kalite-venv_u2404.sh -- if Ubuntu 24.04+ or Mint 22
2024-03-06 18:26:47 +00:00
command : bash "{{ iiab_dir }}/scripts/install_python2_kalite-venv_u2404.sh"
2024-03-07 07:03:29 +00:00
when : is_ubuntu and not is_linuxmint and os_ver is version('ubuntu-2404', '>=') or is_linuxmint_22
2017-05-27 18:09:50 +00:00
2021-03-07 20:34:04 +00:00
- name : "Install from templates: venv wrapper /usr/bin/kalite, unit file /etc/systemd/system/kalite-serve.service"
2017-12-08 06:33:31 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items :
2020-05-17 02:48:52 +00:00
- { src: 'kalite.sh.j2', dest: '/usr/bin/kalite', mode : '0755' }
- { src: 'kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode : '0644' }
2022-10-28 23:00:24 +00:00
- name: Fix KA Lite bug in regex parsing ifconfig output (ifcfg/parser.py) for @m-anish's network names that contain dashes # WAS : if Raspbian/Debian > 10 or Ubuntu > 19
2019-06-13 18:25:09 +00:00
replace :
2021-07-19 15:01:31 +00:00
path : "{{ kalite_venv }}/lib/python2.7/site-packages/kalite/packages/dist/ifcfg/parser.py" # /usr/local/kalite/venv
2019-06-13 18:25:09 +00:00
regexp : 'a-zA-Z0-9'
replace : 'a-zA-Z0-9\-'
2020-01-12 22:06:24 +00:00
2020-02-18 01:00:17 +00:00
- name : Create dir {{ kalite_root }}
file :
state : directory
path : "{{ kalite_root }}/httpsrv/static" # /library/ka-lite
2021-03-07 20:45:25 +00:00
- name : Run '{{ kalite_program }} manage setup ...'
2020-02-18 01:00:17 +00:00
command : "{{ kalite_program }} manage setup --username={{ kalite_admin_user }} --password={{ kalite_admin_password }} --noinput" # Runs /usr/local/kalite/venv/bin/kalite
environment :
KALITE_HOME : "{{ kalite_root }}" # /library/ka-lite
async : 1800
poll : 10
2020-01-30 09:00:00 +00:00
2021-07-07 04:13:52 +00:00
# RECORD KA Lite AS INSTALLED
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'kalite_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : kalite
option : kalite_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2020-02-18 01:00:17 +00:00
- name : "Set 'kalite_installed: True'"
set_fact :
kalite_installed : True
- name : "Add 'kalite_installed: True' to {{ iiab_state_file }}"
lineinfile :
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp : '^kalite_installed'
line: 'kalite_installed : True '