From 38e99031d73bdabcd4f657999595e0a919315472 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 17 Mar 2023 06:10:08 -0500 Subject: [PATCH 01/10] virtual env for ansible --- scripts/ansible | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 5caf055df..e308dac6a 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -160,10 +160,10 @@ fi ###echo -e 'ENSURE ANSIBLE UPDATES CLEANLY: (then re-run this script to be sure!)\n' ###grep '^deb .*ansible' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | grep -v '^/etc/apt/sources.list.d/iiab-ansible.list:' || true # Override bash -e (instead of aborting at 1st error) -echo -e "\napt update; apt install python3-pip # Also installs 'python3-setuptools' and 'python3' etc" +#echo -e "\napt update; apt install python3-pip # Also installs 'python3-setuptools' and 'python3' etc" #echo -e "https://github.com/iiab/iiab/blob/master/scripts/ansible.md\n" -$APT_PATH/apt update -$APT_PATH/apt -y install python3-pip +#$APT_PATH/apt update +#$APT_PATH/apt -y install python3-pip # 2021-07-29: # 'python3-packaging' dropped for now @@ -185,15 +185,28 @@ $APT_PATH/apt -y install python3-pip # https://github.com/iiab/iiab/pull/3022 pip3 config --global set global.no-cache-dir false -if ! uname -m | grep -q 64; then +#if ! uname -m | grep -q 64; then # echo "2022-11-09: ansible-core 2.12.10+ PPA works on 32-bit RasPiOS, using /etc/apt/sources.list.d/iiab-ansible.list, until upstream wheels -> cryptography is fixed (PR #3421)" # $APT_PATH/apt -y --allow-downgrades install ansible-core - echo -e "\n\n'pip3 install cryptography==39.0.2' will now run:\n" - pip3 install --break-system-packages cryptography==39.0.2 || pip3 install cryptography==39.0.2 # PR #3459 https://www.piwheels.org/project/cryptography/ -- WAS 37.0.4 which as of 2023-01-06 was the "latest compatible with ansible-core available via piwheels.org" -fi +# echo -e "\n\n'pip3 install cryptography==39.0.2' will now run:\n" +# pip3 install --break-system-packages cryptography==39.0.2 || pip3 install cryptography==39.0.2 # PR #3459 https://www.piwheels.org/project/cryptography/ -- WAS 37.0.4 which as of 2023-01-06 was the "latest compatible with ansible-core available via piwheels.org" +#fi -echo -e "\n\n'pip3 install --upgrade ansible-core' will now run:\n" # REMINDER: ansible-core 2.12 (released 2021-11-08) requires Python >= 3.8 -pip3 install --break-system-packages --upgrade ansible-core || pip3 install --upgrade ansible-core # PR #3493: Revert to old syntax if pip < 23.0.1, as flag --break-system-packages (for Python 3.11+ / PEP 668) is brand new in Feb 2023: https://github.com/pypa/pip/pull/11780 +#echo -e "\n\n'pip3 install --upgrade ansible-core' will now run:\n" # REMINDER: ansible-core 2.12 (released 2021-11-08) requires Python >= 3.8 +#pip3 install --break-system-packages --upgrade ansible-core || pip3 install --upgrade ansible-core # PR #3493: Revert to old syntax if pip < 23.0.1, as flag --break-system-packages (for Python 3.11+ / PEP 668) is brand new in Feb 2023: https://github.com/pypa/pip/pull/11780 + +echo -e "\napt update; apt install python3-venv" +$APT_PATH/apt update +$APT_PATH/apt -y install python3-venv + +echo -e "Create virtual envinronment for ansible" +python3 -m venv /usr/local/ansible +/usr/local/ansible/bin/python3 -m pip install --upgrade ansible-core +echo -e "Place ansible on path using symlinks" +cd /usr/local/ansible/bin +for bin in $(ls ansible*); do + ln -sf /usr/local/ansible/bin/$bin /usr/local/bin/$bin +done # (Re)running collection installs appears safe, with --force-with-deps to force # upgrade of collection and dependencies it pulls in. Note Ansible may support From 007df549ab8144c6fbd2b7ba2ec75800b8b23b86 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 17 Mar 2023 17:41:04 -0500 Subject: [PATCH 02/10] Update scripts/ansible Co-authored-by: A Holt --- scripts/ansible | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ansible b/scripts/ansible index e308dac6a..0b88f97f1 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -199,7 +199,7 @@ echo -e "\napt update; apt install python3-venv" $APT_PATH/apt update $APT_PATH/apt -y install python3-venv -echo -e "Create virtual envinronment for ansible" +echo -e "Create virtual environment for ansible" python3 -m venv /usr/local/ansible /usr/local/ansible/bin/python3 -m pip install --upgrade ansible-core echo -e "Place ansible on path using symlinks" From d90227e066ff6c0d34c7fc96f9989ddefca6e8b3 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Mar 2023 22:53:22 -0400 Subject: [PATCH 03/10] venv WIP: scripts/ansible & kalite/tasks/install.yml --- roles/kalite/tasks/install.yml | 2 +- scripts/ansible | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/kalite/tasks/install.yml b/roles/kalite/tasks/install.yml index 6f359395d..5fb192475 100644 --- a/roles/kalite/tasks/install.yml +++ b/roles/kalite/tasks/install.yml @@ -15,7 +15,7 @@ name: - python2 - python-setuptools # Provides setuptools-44 on recent OS's (last version compatible with python2) - - virtualenv # 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} + - 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} state: present #when: not (is_debian_9 or is_debian_10 or is_ubuntu_16 or is_ubuntu_17 or is_ubuntu_18 or is_ubuntu_19) # 2020-03-31: Testing for {is_raspbian_9, is_raspbian_10} is not currently nec, as testing for {is_debian_9, is_debian_10} covers that already. diff --git a/scripts/ansible b/scripts/ansible index 0b88f97f1..d3dda04af 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -160,7 +160,7 @@ fi ###echo -e 'ENSURE ANSIBLE UPDATES CLEANLY: (then re-run this script to be sure!)\n' ###grep '^deb .*ansible' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | grep -v '^/etc/apt/sources.list.d/iiab-ansible.list:' || true # Override bash -e (instead of aborting at 1st error) -#echo -e "\napt update; apt install python3-pip # Also installs 'python3-setuptools' and 'python3' etc" +#echo -e "\napt update; apt install python3-pip # Also installs 'python3-setuptools' and 'python3' etc" #echo -e "https://github.com/iiab/iiab/blob/master/scripts/ansible.md\n" #$APT_PATH/apt update #$APT_PATH/apt -y install python3-pip @@ -183,7 +183,7 @@ fi # cache system-wide before installing: # https://stackoverflow.com/questions/9510474/removing-pips-cache/61762308#61762308 # https://github.com/iiab/iiab/pull/3022 -pip3 config --global set global.no-cache-dir false +#pip3 config --global set global.no-cache-dir false #if ! uname -m | grep -q 64; then # echo "2022-11-09: ansible-core 2.12.10+ PPA works on 32-bit RasPiOS, using /etc/apt/sources.list.d/iiab-ansible.list, until upstream wheels -> cryptography is fixed (PR #3421)" @@ -199,10 +199,10 @@ echo -e "\napt update; apt install python3-venv" $APT_PATH/apt update $APT_PATH/apt -y install python3-venv -echo -e "Create virtual environment for ansible" +echo -e "Create virtual environment for Ansible" python3 -m venv /usr/local/ansible /usr/local/ansible/bin/python3 -m pip install --upgrade ansible-core -echo -e "Place ansible on path using symlinks" +echo -e "Create symlinks /usr/local/bin/ansible* -> /usr/local/ansible/bin/ansible*" cd /usr/local/ansible/bin for bin in $(ls ansible*); do ln -sf /usr/local/ansible/bin/$bin /usr/local/bin/$bin From e589bbce0f62d013553cae158cf73442a417de85 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Mar 2023 22:59:02 -0400 Subject: [PATCH 04/10] venv WIP: calibre-web/tasks/install.yml packages? --- roles/calibre-web/tasks/install.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/calibre-web/tasks/install.yml b/roles/calibre-web/tasks/install.yml index 65a88168c..0b5e70c6d 100644 --- a/roles/calibre-web/tasks/install.yml +++ b/roles/calibre-web/tasks/install.yml @@ -3,6 +3,8 @@ name: - imagemagick - python3-venv + - python3-dev + - build-essential state: present - name: Allow ImageMagick to read PDFs, per /etc/ImageMagick-6/policy.xml, to create book cover thumbnails From cfb446479dd7183375c79efbddedef30c9ce7f46 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Mar 2023 23:36:31 -0400 Subject: [PATCH 05/10] venv cleanups: lokole, calibre-web, pip stub for Admin Console --- roles/9-local-addons/tasks/main.yml | 5 +++++ roles/calibre-web/tasks/install.yml | 4 ++-- roles/lokole/tasks/install.yml | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/roles/9-local-addons/tasks/main.yml b/roles/9-local-addons/tasks/main.yml index e8ab5d14b..0a2f800d5 100644 --- a/roles/9-local-addons/tasks/main.yml +++ b/roles/9-local-addons/tasks/main.yml @@ -42,6 +42,11 @@ name: pbx when: pbx_install +- name: "INSTALL python3-pip FOR ADMIN CONSOLE 'cmdsrv : Download speedtest-cli' -- SEE PR #3494 -- REMOVE THIS CODE LATER" + package: + name: python3-pip + state: present + - name: Recording STAGE 9 HAS COMPLETED ==================== lineinfile: path: "{{ iiab_env_file }}" diff --git a/roles/calibre-web/tasks/install.yml b/roles/calibre-web/tasks/install.yml index 0b5e70c6d..1bbb6623b 100644 --- a/roles/calibre-web/tasks/install.yml +++ b/roles/calibre-web/tasks/install.yml @@ -1,9 +1,9 @@ -- name: "Install packages: imagemagick, python3-venv" +- name: "Install packages: imagemagick, python3-venv, build-essential" package: name: - imagemagick - python3-venv - - python3-dev + #- python3-dev - build-essential state: present diff --git a/roles/lokole/tasks/install.yml b/roles/lokole/tasks/install.yml index a1ea1d357..82d8593ca 100644 --- a/roles/lokole/tasks/install.yml +++ b/roles/lokole/tasks/install.yml @@ -2,11 +2,11 @@ # https://github.com/iiab/iiab/blob/master/roles/www_base/templates/iiab-refresh-wiki-docs.sh#L51-L52 -- name: Install 14 packages for Lokole +- name: Install 13 packages for Lokole apt: name: #- python3 # 2022-12-21: IIAB pre-req, see scripts/local_facts.fact - - python3-pip + #- python3-pip - python3-venv - python3-dev - python3-bcrypt # 2019-10-14: Should work across modern Linux OS's From aad12eb928adf81f0f22d51551ad3e083a586d8a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 18 Mar 2023 00:27:22 -0400 Subject: [PATCH 06/10] scripts/ansible: Cleaner on-screen output --- scripts/ansible | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index d3dda04af..73fb028e1 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -199,10 +199,10 @@ echo -e "\napt update; apt install python3-venv" $APT_PATH/apt update $APT_PATH/apt -y install python3-venv -echo -e "Create virtual environment for Ansible" +echo -e "\nCreate virtual environment for Ansible" python3 -m venv /usr/local/ansible /usr/local/ansible/bin/python3 -m pip install --upgrade ansible-core -echo -e "Create symlinks /usr/local/bin/ansible* -> /usr/local/ansible/bin/ansible*" +echo -e "\nCreate symlinks /usr/local/bin/ansible* -> /usr/local/ansible/bin/ansible*" cd /usr/local/ansible/bin for bin in $(ls ansible*); do ln -sf /usr/local/ansible/bin/$bin /usr/local/bin/$bin From 7db4dc546eee203484e8311ad5c9aa12dfd78025 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 18 Mar 2023 12:25:02 -0400 Subject: [PATCH 07/10] Revert #3422 block of JupyterHub & Caliber-Web on 32-bit HW [should've blocked 32-bit OS's] --- roles/6-generic-apps/tasks/main.yml | 2 +- roles/9-local-addons/tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/6-generic-apps/tasks/main.yml b/roles/6-generic-apps/tasks/main.yml index 648991a4f..f43e878f3 100644 --- a/roles/6-generic-apps/tasks/main.yml +++ b/roles/6-generic-apps/tasks/main.yml @@ -29,7 +29,7 @@ - name: JUPYTERHUB include_role: name: jupyterhub - when: jupyterhub_install and ansible_machine is search("64") # 2022-11-10: Avoid installing on 32-bit, until RasPiOS fixes Rust (PR #3421) + when: jupyterhub_install # UNMAINTAINED - name: LOKOLE diff --git a/roles/9-local-addons/tasks/main.yml b/roles/9-local-addons/tasks/main.yml index 0a2f800d5..bf983a322 100644 --- a/roles/9-local-addons/tasks/main.yml +++ b/roles/9-local-addons/tasks/main.yml @@ -27,7 +27,7 @@ - name: CALIBRE-WEB include_role: name: calibre-web - when: calibreweb_install and ansible_machine is search("64") # 2022-11-10: Avoid installing on 32-bit, until RasPiOS fixes Rust (PR #3421) + when: calibreweb_install # KEEP NEAR THE VERY END as this installs dependencies from Debian's 'testing' branch! - name: CALIBRE From 9c28f88cb234a701ea11589582f9070710254b7a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 18 Mar 2023 12:42:25 -0400 Subject: [PATCH 08/10] 9-local-addons: Install python3-pip 'when: admin_console_install' --- roles/9-local-addons/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/9-local-addons/tasks/main.yml b/roles/9-local-addons/tasks/main.yml index bf983a322..548fac45f 100644 --- a/roles/9-local-addons/tasks/main.yml +++ b/roles/9-local-addons/tasks/main.yml @@ -46,6 +46,7 @@ package: name: python3-pip state: present + when: admin_console_install - name: Recording STAGE 9 HAS COMPLETED ==================== lineinfile: From 95d83000335e579f74de691d3e3b121f23308fb7 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 18 Mar 2023 19:57:17 -0400 Subject: [PATCH 09/10] 9-local-addons: Stub install python3-jinja2 for Admin Console --- roles/9-local-addons/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/9-local-addons/tasks/main.yml b/roles/9-local-addons/tasks/main.yml index 548fac45f..1b41b0dc7 100644 --- a/roles/9-local-addons/tasks/main.yml +++ b/roles/9-local-addons/tasks/main.yml @@ -42,9 +42,11 @@ name: pbx when: pbx_install -- name: "INSTALL python3-pip FOR ADMIN CONSOLE 'cmdsrv : Download speedtest-cli' -- SEE PR #3494 -- REMOVE THIS CODE LATER" +- name: "INSTALL python3-pip FOR ADMIN CONSOLE 'cmdsrv : Download speedtest-cli' SEE PR #3494 -- INSTALL python3-jinja2 FOR ADMIN CONSOLE 'js-menu : Post process the downloaded menu defs' SEE PR #3496 -- REMOVE THIS CODE LATER" package: - name: python3-pip + name: + - python3-pip + - python3-jinja2 state: present when: admin_console_install From ec855c2ff945f09aa51cc5ba955f2911f804cc5a Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 18 Mar 2023 20:14:03 -0400 Subject: [PATCH 10/10] Document "/usr/local/ansible/bin/pip3 show ansible-core" --- scripts/ansible | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ansible b/scripts/ansible index 73fb028e1..b077bdde7 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -229,6 +229,7 @@ ansible-galaxy collection install --force-with-deps \ echo -e "\n\nSUCCESS! PLEASE VERIFY ANSIBLE WITH COMMANDS LIKE:\n" echo -e " ansible --version" +echo -e " /usr/local/ansible/bin/pip3 show ansible-core" echo -e " pip3 show ansible-core" echo -e ' apt -a list "ansible*"' echo -e " ansible-galaxy collection list\n"