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 diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index d95f36044..0d7887207 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -61,6 +61,35 @@ 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: + # 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 + + # 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 + 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 @@ -71,17 +100,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 @@ -124,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 @@ -133,27 +168,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: diff --git a/roles/kolibri/tasks/main.yml b/roles/kolibri/tasks/main.yml index 1af098232..9ae375758 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) 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 when: kolibri_installed is undefined diff --git a/roles/kolibri/tasks/pip-install.yml b/roles/kolibri/tasks/pip-install.yml new file mode 100644 index 000000000..29594e964 --- /dev/null +++ b/roles/kolibri/tasks/pip-install.yml @@ -0,0 +1,66 @@ +- name: Remove kolibri 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 }}" + state: absent + +# 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 + - wheel + - setuptools + - legacy-cgi + 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: + 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" + 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: + src: "{{ kolibri_venv_path }}/bin/kolibri" + dest: "{{ kolibri_exec_path }}" + state: link + force: true