diff --git a/defaults/main.yml b/defaults/main.yml index dd1cfe3a..27243b1d 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -236,3 +236,6 @@ openwisp2_radius_periodic_tasks: true openwisp2_usage_metric_collection_periodic_tasks: true # point {{ inventory_name }} to localhost in /etc/hosts openwisp2_inventory_hostname_localhost: true +# openwisp2_pip_extra_args controls extra pip arguments used when installing or +# reinstalling OpenWISP Python packages and dependencies. +openwisp2_pip_extra_args: "--upgrade" diff --git a/docs/user/role-variables.rst b/docs/user/role-variables.rst index c840d8f8..70770452 100644 --- a/docs/user/role-variables.rst +++ b/docs/user/role-variables.rst @@ -31,6 +31,11 @@ take a look at `the default values of these variables openwisp2_monitoring_version: "openwisp-monitoring~=1.0.0" openwisp2_radius_version: "openwisp-radius~=1.0.0" openwisp2_django_version: "django~=3.2.13" + # Extra arguments passed to pip when reinstalling Python packages with --force-reinstall + # By default, packages are upgraded on each playbook run. + # Can be overridden, for example: + # openwisp2_pip_extra_args: "--upgrade --force-reinstall" + openwisp2_pip_extra_args: "--upgrade" # Setting this to true will enable subnet division feature of # openwisp-controller. Refer openwisp-controller documentation # for more information. https://github.com/openwisp/openwisp-controller#subnet-division-app diff --git a/tasks/pip.yml b/tasks/pip.yml index 846621f9..feb9d96a 100644 --- a/tasks/pip.yml +++ b/tasks/pip.yml @@ -22,6 +22,7 @@ state: latest virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" environment: LC_CTYPE: "en_US.UTF-8" notify: Reload application @@ -43,6 +44,7 @@ requirements: "{{ openwisp2_path }}/requirements.txt" virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" notify: Reload application retries: 5 delay: 10 @@ -58,6 +60,7 @@ state: latest virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" notify: Reload application retries: 5 delay: 10 @@ -73,6 +76,7 @@ state: latest virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" notify: Reload application retries: 5 delay: 10 @@ -88,6 +92,7 @@ state: latest virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" notify: Reload application retries: 5 delay: 10 @@ -103,6 +108,7 @@ state: latest virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" notify: Reload application retries: 5 delay: 10 @@ -123,6 +129,7 @@ requirements: "{{ openwisp2_path }}/requirements-cors-headers.txt" virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" when: openwisp2_django_cors.get('enabled') retries: 5 delay: 10 @@ -155,6 +162,7 @@ requirements: "{{ openwisp2_path }}/requirements-postgresql.txt" virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" when: openwisp2_database.engine in ["django.db.backends.postgresql", "django.contrib.gis.db.backends.postgis"] retries: 5 delay: 10 @@ -174,6 +182,7 @@ requirements: "{{ openwisp2_path }}/requirements-mysql.txt" virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" when: openwisp2_database.engine in ["django.db.backends.mysql", "django.contrib.gis.db.backends.mysql"] retries: 5 delay: 10 @@ -214,6 +223,7 @@ requirements: "{{ openwisp2_path }}/requirements-celery-email.txt" virtualenv: "{{ virtualenv_path }}" virtualenv_python: "{{ openwisp2_python }}" + extra_args: "{{ openwisp2_pip_extra_args }}" when: openwisp2_email_backend == "djcelery_email.backends.CeleryEmailBackend" notify: Reload application retries: 5