From 2adc21f6fc13a15a09aad9510e472385427add52 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 16 Feb 2025 21:16:22 -0600 Subject: [PATCH 01/11] defaults --- roles/kolibri/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/kolibri/defaults/main.yml b/roles/kolibri/defaults/main.yml index 80eb0c352..9653af73e 100644 --- a/roles/kolibri/defaults/main.yml +++ b/roles/kolibri/defaults/main.yml @@ -61,3 +61,5 @@ kolibri_admin_password: changeme # Kolibri Preset type: formal, nonformal, informal kolibri_preset: formal + +kolibri_venv_path: /usr/local/kolibri From c20caee3cb0d1440fcf4f33c178be2953e5d876d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 10:52:25 -0600 Subject: [PATCH 02/11] pip-install.yml --- roles/kolibri/tasks/pip-install.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 roles/kolibri/tasks/pip-install.yml diff --git a/roles/kolibri/tasks/pip-install.yml b/roles/kolibri/tasks/pip-install.yml new file mode 100644 index 000000000..9bdcc2119 --- /dev/null +++ b/roles/kolibri/tasks/pip-install.yml @@ -0,0 +1,29 @@ +- name: Remove previous virtual environment {{ kolibri_venv_path }} + file: + path: "{{ kolibri_venv_path }}" + state: absent + +- name: Install prep for kolibri + pip: + name: + - pip + - wheel + - setuptools + - legacy-cgi + virtualenv: "{{ kolibri_venv_path }}" + virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" + extra_args: "--no-cache-dir --prefer-binary" + +- name: Install kolibri {{ kolibri_version_pip }} using pip + pip: + name: kolibri + version: "{{ kolibri_version_pip }}" + virtualenv: "{{ kolibri_venv_path }}" + virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" + extra_args: "--no-cache-dir --prefer-binary --ignore-requires-python" + +- name: Create {{ kolibri_exec_path }} symlink to {{ kolibri_venv_path }}/bin/kolibri + file: + src: "{{ kolibri_venv_path }}/bin/kolibri" + dest: "{{ kolibri_exec_path }}" + state: link From fd91a8b238659c9866af5ffa4959b49136636414 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 10:59:40 -0600 Subject: [PATCH 03/11] block for apt & call pip-install.yml --- roles/kolibri/tasks/install.yml | 44 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index d95f36044..c34b1ce87 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -61,7 +61,11 @@ content: 'KOLIBRI_HOME="{{ kolibri_home }}"' dest: /etc/kolibri/daemon.conf +- name: Using PIP method + include_tasks: pip-install.yml + when: kolibri_version_pip is defined +- block: # https://kolibri.readthedocs.io/en/latest/install/ubuntu-debian.html claims: # "When you use the PPA installation method, upgrades to newer versions # will be automatic, provided there is internet access available." @@ -71,17 +75,17 @@ # https://github.com/learningequality/kolibri-installer-debian/pull/117 # 2022-08-31: keyring /etc/apt/trusted.gpg DEPRECATED as detailed on #3343 -- name: Download Kolibri's apt key to /usr/share/keyrings/learningequality-kolibri.gpg - shell: | - gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys DC5BAA93F9E4AE4F0411F97C74F88ADB3194DD81 - gpg --yes --output /usr/share/keyrings/learningequality-kolibri.gpg --export DC5BAA93F9E4AE4F0411F97C74F88ADB3194DD81 + - name: Download Kolibri's apt key to /usr/share/keyrings/learningequality-kolibri.gpg + shell: | + gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys DC5BAA93F9E4AE4F0411F97C74F88ADB3194DD81 + gpg --yes --output /usr/share/keyrings/learningequality-kolibri.gpg --export DC5BAA93F9E4AE4F0411F97C74F88ADB3194DD81 # 2024-06-25: Strongly consider PPA "kolibri-proposed" in future... # https://github.com/learningequality/kolibri/issues/11892 # https://kolibri.readthedocs.io/en/latest/install/ubuntu-debian.html -- name: Add signed Kolibri PPA 'jammy' - apt_repository: - repo: "deb [signed-by=/usr/share/keyrings/learningequality-kolibri.gpg] http://ppa.launchpad.net/learningequality/kolibri/ubuntu jammy main" + - name: Add signed Kolibri PPA 'jammy' + apt_repository: + repo: "deb [signed-by=/usr/share/keyrings/learningequality-kolibri.gpg] http://ppa.launchpad.net/learningequality/kolibri/ubuntu jammy main" # when: is_ubuntu and os_ver is version('ubuntu-2204', '>=') or is_linuxmint_21 or is_debian_12 # #when: is_ubuntu_2204 or is_ubuntu_2210 or is_debian_12 # MINT 21 COVERED BY is_ubuntu_2204 @@ -133,27 +137,29 @@ # kolibri_deb_url: https://github.com/learningequality/kolibri/releases/download/v0.17.0/kolibri_0.17.0-0ubuntu1_all.deb # when: python_version is version('3.12', '>=') # For Ubuntu 24.04, Mint 22, pre-releases of Ubuntu 24.10, and Debian 13 (even if/when "Trixie" changes from Python 3.12 to 3.13!) Regarding PPA kolibri-proposed not quite being ready yet, see: learningequality/kolibri#11316 -> learningequality/kolibri#11892 -- name: apt install kolibri (using apt source specified above, if kolibri_deb_url ISN'T defined) - apt: - name: kolibri - when: kolibri_deb_url is undefined + - name: apt install kolibri (using apt source specified above, if kolibri_deb_url ISN'T defined) + apt: + name: kolibri + when: kolibri_deb_url is undefined # environment: # KOLIBRI_HOME: "{{ kolibri_home }}" # 2023-03-27: These don't do a thing # KOLIBRI_USER: "{{ kolibri_user }}" # for now. -- name: apt install {{ kolibri_deb_url }} (if kolibri_deb_url IS defined) - apt: - deb: "{{ kolibri_deb_url }}" # e.g. https://learningequality.org/r/kolibri-deb-latest - when: kolibri_deb_url is defined + - name: apt install {{ kolibri_deb_url }} (if kolibri_deb_url IS defined) + apt: + deb: "{{ kolibri_deb_url }}" # e.g. https://learningequality.org/r/kolibri-deb-latest + when: kolibri_deb_url is defined # environment: # KOLIBRI_HOME: "{{ kolibri_home }}" # 2023-03-27: These don't do a thing # KOLIBRI_USER: "{{ kolibri_user }}" # for now. -- name: Run 'rm -rf /root/.kolibri' to remove "unavoidable" pollution created above - file: - state: absent - path: /root/.kolibri + - name: Run 'rm -rf /root/.kolibri' to remove "unavoidable" pollution created above + file: + state: absent + path: /root/.kolibri +# end block + when: kolibri_version_pip is undefined - name: 'Install from template: /etc/systemd/system/kolibri.service' template: From ff7815913f9ff1f5dbc99c6ab5e041d2d6353e5d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 11:00:17 -0600 Subject: [PATCH 04/11] kolibri_version_pip --- roles/kolibri/tasks/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/roles/kolibri/tasks/main.yml b/roles/kolibri/tasks/main.yml index 1af098232..259792ec1 100644 --- a/roles/kolibri/tasks/main.yml +++ b/roles/kolibri/tasks/main.yml @@ -26,6 +26,11 @@ # kolibri_provision: False # when: ??? + - name: Set kolibri_version_pip if + set_fact: + kolibri_version_pip: 0.17.5 + when: is_debian_13 or is_ubuntu_2504 + - name: Install Kolibri, if 'kolibri_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml include_tasks: install.yml when: kolibri_installed is undefined From 35dcc032ac19690659462e03fc9a11eb2fa7c817 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 12:10:11 -0600 Subject: [PATCH 05/11] handle upgrades --- roles/kolibri/tasks/pip-install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/kolibri/tasks/pip-install.yml b/roles/kolibri/tasks/pip-install.yml index 9bdcc2119..c6362c52b 100644 --- a/roles/kolibri/tasks/pip-install.yml +++ b/roles/kolibri/tasks/pip-install.yml @@ -27,3 +27,4 @@ src: "{{ kolibri_venv_path }}/bin/kolibri" dest: "{{ kolibri_exec_path }}" state: link + force: true From b64bc95e0e8567e30a377b7e267ff1b2ea7a894d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 13:21:03 -0600 Subject: [PATCH 06/11] should allow for a local_vars override The thought is once a new release from upstream comes along should be able to set the fact in local_vars and reinstall to the listed version via pip without waiting for the deb to be released. OR If one wants to use a virtual environment from the start. --- roles/kolibri/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/kolibri/tasks/main.yml b/roles/kolibri/tasks/main.yml index 259792ec1..9ae375758 100644 --- a/roles/kolibri/tasks/main.yml +++ b/roles/kolibri/tasks/main.yml @@ -29,7 +29,7 @@ - name: Set kolibri_version_pip if set_fact: kolibri_version_pip: 0.17.5 - when: is_debian_13 or is_ubuntu_2504 + when: (is_debian_13 or is_ubuntu_2504) and kolibri_version_pip is undefined - name: Install Kolibri, if 'kolibri_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml include_tasks: install.yml From d0fe047538f86731d8c47930d72bdfd183b82838 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 13:57:38 -0600 Subject: [PATCH 07/11] handle pip to deb upgrades --- roles/kolibri/tasks/install.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index c34b1ce87..81e879b41 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -66,6 +66,18 @@ when: kolibri_version_pip is defined - block: + # handles going from pip to deb installs during --reinstall + - name: Test for {{ kolibri_exec_path }} + ansible.builtin.stat: + path: "{{ kolibri_exec_path }}" + register: sym + + - name: Remove if {{ kolibri_exec_path }} is a symlink + file: + state: absent + path: "{{ kolibri_exec_path }}" + when: sym.stat.islnk is defined and sym.stat.islnk + # end test # https://kolibri.readthedocs.io/en/latest/install/ubuntu-debian.html claims: # "When you use the PPA installation method, upgrades to newer versions # will be automatic, provided there is internet access available." From 6d1d4105f33d0b7e9a2e8b47163e1495a6bd0b4e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 16:30:52 -0600 Subject: [PATCH 08/11] pip-install - always uninstall deb and repo if present --- roles/kolibri/tasks/pip-install.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/kolibri/tasks/pip-install.yml b/roles/kolibri/tasks/pip-install.yml index c6362c52b..cb5ac62d4 100644 --- a/roles/kolibri/tasks/pip-install.yml +++ b/roles/kolibri/tasks/pip-install.yml @@ -1,3 +1,13 @@ +- name: Remove kolibre deb if installed + apt: + name: kolibri + state: "absent" + +- name: Remove repo if present + file: + path: /etc/apt/sources.list.d/ppa_launchpad_net_learningequality_kolibri_ubuntu.list + state: absent + - name: Remove previous virtual environment {{ kolibri_venv_path }} file: path: "{{ kolibri_venv_path }}" From d1c8979d5b447c8a163659e6f0650deba7f7b559 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 16:46:15 -0600 Subject: [PATCH 09/11] install.yml deb block always remove venv if present --- roles/kolibri/tasks/install.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index 81e879b41..026088eb4 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -78,6 +78,12 @@ path: "{{ kolibri_exec_path }}" when: sym.stat.islnk is defined and sym.stat.islnk # end test + + - name: Remove virtual environment {{ kolibri_venv_path }} if present + file: + path: "{{ kolibri_venv_path }}" + state: absent + # https://kolibri.readthedocs.io/en/latest/install/ubuntu-debian.html claims: # "When you use the PPA installation method, upgrades to newer versions # will be automatic, provided there is internet access available." From 88243f840f8e8efcf0d6e45387617a87d3a06478 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 20 Feb 2025 21:03:27 -0600 Subject: [PATCH 10/11] kolibri_version_pip_web --- roles/kolibri/tasks/pip-install.yml | 30 +++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/roles/kolibri/tasks/pip-install.yml b/roles/kolibri/tasks/pip-install.yml index cb5ac62d4..29594e964 100644 --- a/roles/kolibri/tasks/pip-install.yml +++ b/roles/kolibri/tasks/pip-install.yml @@ -1,4 +1,4 @@ -- name: Remove kolibre deb if installed +- name: Remove kolibri deb if installed apt: name: kolibri state: "absent" @@ -13,7 +13,21 @@ path: "{{ kolibri_venv_path }}" state: absent -- name: Install prep for kolibri +# can't hurt but should be called in as a dependency +- name: Install prep for kolibri when NOT is_debian_13 or is_ubuntu_2504 + pip: + name: + - pip + - wheel + - setuptools + - cgi + virtualenv: "{{ kolibri_venv_path }}" + virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" + extra_args: "--no-cache-dir --prefer-binary" + when: not (is_debian_13 or is_ubuntu_2504) + +# package name change +- name: Install prep for kolibri when is_debian_13 or is_ubuntu_2504 pip: name: - pip @@ -23,6 +37,7 @@ virtualenv: "{{ kolibri_venv_path }}" virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" extra_args: "--no-cache-dir --prefer-binary" + when: (is_debian_13 or is_ubuntu_2504) - name: Install kolibri {{ kolibri_version_pip }} using pip pip: @@ -31,6 +46,17 @@ virtualenv: "{{ kolibri_venv_path }}" virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" extra_args: "--no-cache-dir --prefer-binary --ignore-requires-python" + when: kolibri_version_pip_web is undefined + +# use kolibri_version_pip_web: https://github.com/learningequality/kolibri/releases/download/ and set kolibri_version_pip +# and not the full path note v0.18.0-alpha1/kolibri-0.18.0a1-py2.py3-none-any.whl +- name: Install kolibri using {{ kolibri_version_pip_web }}/{{ kolibri_version_pip }}-py2.py3-none-any.whl + pip: + name: "{{ kolibri_version_pip_web }}/kolibri-{{ kolibri_version_pip }}-py2.py3-none-any.whl" + virtualenv: "{{ kolibri_venv_path }}" + virtualenv_command: python3 -m venv "{{ kolibri_venv_path }}" + extra_args: "--no-cache-dir --prefer-binary --ignore-requires-python" + when: kolibri_version_pip_web is defined - name: Create {{ kolibri_exec_path }} symlink to {{ kolibri_venv_path }}/bin/kolibri file: From 1bec10f874b51b4535d2508bd25620e72f6dfca3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 17 Feb 2025 16:03:54 -0600 Subject: [PATCH 11/11] Needs discussion --- roles/kolibri/tasks/install.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index 026088eb4..0d7887207 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -77,6 +77,13 @@ state: absent path: "{{ kolibri_exec_path }}" when: sym.stat.islnk is defined and sym.stat.islnk + + # should not get here if the deb was uninstalled in pip-install.yml + - name: Remove kolibre deb if installed + apt: + name: kolibri + state: "absent" + when: sym.stat.islnk is defined and sym.stat.islnk # end test - name: Remove virtual environment {{ kolibri_venv_path }} if present @@ -146,6 +153,12 @@ # codename: focal # UPDATE THIS TO 'jammy' AFTER "RasPiOS Bookworm" (based on Debian 12) IS RELEASED! (ETA Q3 2023) # when: is_debian or is_linuxmint_20 +# Needs discussiion +# --reinstalls should work uninstall then install +# - name: Remove kolibre deb if installed +# apt: +# name: kolibri +# state: "absent" # 2024-08-07: Hack no longer needed! As Kolibri 0.17.0 now installs via "kolibri" PPA (https://launchpad.net/~learningequality/+archive/ubuntu/kolibri). # Hopefully "kolibri-proposed" PPA will install 0.18 pre-releases soon, on Python 3.13 too! https://github.com/learningequality/kolibri/issues/11892