From b50ef7940903d56b55ca8755b8eaee3e381ecbb2 Mon Sep 17 00:00:00 2001 From: emsu-io-suefke <113017485+emsu-io-suefke@users.noreply.github.com> Date: Tue, 18 Oct 2022 14:00:44 +0200 Subject: [PATCH] [fix] Fixed Python <3.7 Running $ ansible-playbook -i hosts playbook.yml -u user --check would always result in an error because the variable {{openwisp2_installed_python}} would never have been set when running with --check. It is Ansible best practice to use Ansible native checks wherever possible and it is reasonable to assume that Ansible runs in the Python version the system has. For Python version checking, see https://serverfault.com/a/858684 Another change is to install >= Python 3.7 only if < Python 3.7 is found. The old expression would install deadsnakes-python3.7 over system python3.7 --- tasks/apt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/apt.yml b/tasks/apt.yml index 550da83e..3385f137 100644 --- a/tasks/apt.yml +++ b/tasks/apt.yml @@ -142,7 +142,7 @@ - name: Check openwisp2 should install python 3.7 set_fact: openwisp2_should_install_python_37: | - {{ openwisp2_installed_python.stdout.split(' ')[1] is version_compare('3.7', 'le') }} + {{ ansible_python_version is version_compare('3.7', 'lt') }} - name: Install Python 3.7 and required packages from ppa:deadsnakes/ppa block: