From 6b011079c21957160677aea1de0f5913c170a8f1 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sat, 22 Oct 2022 19:46:37 +1300 Subject: [PATCH 1/7] deprecate venv creation when missing --- .../web_infrastructure/django_manage.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py index 0d68e926eb1..d3ac799dd52 100644 --- a/plugins/modules/web_infrastructure/django_manage.py +++ b/plugins/modules/web_infrastructure/django_manage.py @@ -111,9 +111,11 @@ aliases: [test_runner] notes: - C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter - is specified. + is specified. This requirement is deprecated and will be removed in community.general version 9.0.0. - This module will create a virtualenv if the I(virtualenv) parameter is specified and a virtual environment does not already - exist at the given location. + exist at the given location. This behavior is deprecated and will be removed in community.general version 9.0.0. + - The parameter I(virtualenv) will remain in use, but it will require the specified virtualenv to exist. + The recommended way to create one in Ansible is by using M(ansible.builtin.pip). - This module assumes English error messages for the C(createcachetable) command to detect table existence, unfortunately. - To be able to use the C(migrate) command with django versions < 1.7, you must have C(south) installed and added @@ -179,10 +181,21 @@ def _ensure_virtualenv(module): if venv_param is None: return + ack_venv_deprecation = module.params['ack_venv_creation_deprecation'] + vbin = os.path.join(venv_param, 'bin') activate = os.path.join(vbin, 'activate') if not os.path.exists(activate): + # In version 9.0.0, if the venv is not found, it should fail_json() here. + if not ack_venv_deprecation: + module.deprecate( + 'The behavior of "creating the virtual environment when missing" is being ' + 'deprecated and will be removed in community.general version 9.0.0. ' + 'Set the module parameter `ack_venv_creation_deprecation: true` to ' + 'prevent this message from showing up in every run.' + ) + virtualenv = module.get_bin_path('virtualenv', True) vcmd = [virtualenv, venv_param] rc, out_venv, err_venv = module.run_command(vcmd) @@ -272,6 +285,7 @@ def main(): skip=dict(type='bool'), merge=dict(type='bool'), link=dict(type='bool'), + ack_venv_creation_deprecation=dict(type='bool'), ), ) From d1941825993c45edd2eeb6e9c956ccfd9b57bcd7 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sat, 22 Oct 2022 19:52:36 +1300 Subject: [PATCH 2/7] add changelog fragment --- changelogs/fragments/5404-django-manage-venv-deprecation.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/fragments/5404-django-manage-venv-deprecation.yml diff --git a/changelogs/fragments/5404-django-manage-venv-deprecation.yml b/changelogs/fragments/5404-django-manage-venv-deprecation.yml new file mode 100644 index 00000000000..f1ab1d55987 --- /dev/null +++ b/changelogs/fragments/5404-django-manage-venv-deprecation.yml @@ -0,0 +1,5 @@ +deprecated_features: + - >- + django_manage - The behavior of "creating the virtual environment when missing" + is being deprecated and will be removed in community.general version 9.0.0 + (https://github.com/ansible-collections/community.general/pull/5405). From 9c8a4e51e7301f66b51da5c2e9c11fd658dcea03 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sat, 22 Oct 2022 21:29:13 +1300 Subject: [PATCH 3/7] fix sanity checks --- plugins/modules/web_infrastructure/django_manage.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py index d3ac799dd52..584ebbb26d3 100644 --- a/plugins/modules/web_infrastructure/django_manage.py +++ b/plugins/modules/web_infrastructure/django_manage.py @@ -109,6 +109,14 @@ type: str required: false aliases: [test_runner] + ack_venv_creation_deprecation: + description: + - >- + When a I(virtualenv) is set but the virtual environment does not exist, the current behavior is + to create a new virtual environment. That behavior is deprecated and if that case happens it will + generate a deprecation warning. Set this flag to C(true) to suppress the deprecation warning. + type: bool + notes: - C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter is specified. This requirement is deprecated and will be removed in community.general version 9.0.0. @@ -193,7 +201,9 @@ def _ensure_virtualenv(module): 'The behavior of "creating the virtual environment when missing" is being ' 'deprecated and will be removed in community.general version 9.0.0. ' 'Set the module parameter `ack_venv_creation_deprecation: true` to ' - 'prevent this message from showing up in every run.' + 'prevent this message from showing up when creating a virtualenv.', + version='9.0.0', + collection_name='community.general', ) virtualenv = module.get_bin_path('virtualenv', True) From bdba527a31eaa160d5203463fc5ca3b57c08d44b Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:36:14 +1300 Subject: [PATCH 4/7] Update changelogs/fragments/5404-django-manage-venv-deprecation.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5404-django-manage-venv-deprecation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/5404-django-manage-venv-deprecation.yml b/changelogs/fragments/5404-django-manage-venv-deprecation.yml index f1ab1d55987..f6a8e6e01eb 100644 --- a/changelogs/fragments/5404-django-manage-venv-deprecation.yml +++ b/changelogs/fragments/5404-django-manage-venv-deprecation.yml @@ -1,5 +1,5 @@ deprecated_features: - >- - django_manage - The behavior of "creating the virtual environment when missing" + django_manage - the behavior of "creating the virtual environment when missing" is being deprecated and will be removed in community.general version 9.0.0 (https://github.com/ansible-collections/community.general/pull/5405). From bfa790b8f84e9fd1dad14b614aa9093b92bd4513 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:36:37 +1300 Subject: [PATCH 5/7] Update plugins/modules/web_infrastructure/django_manage.py Co-authored-by: Felix Fontein --- plugins/modules/web_infrastructure/django_manage.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py index 584ebbb26d3..44638b04f9d 100644 --- a/plugins/modules/web_infrastructure/django_manage.py +++ b/plugins/modules/web_infrastructure/django_manage.py @@ -115,6 +115,8 @@ When a I(virtualenv) is set but the virtual environment does not exist, the current behavior is to create a new virtual environment. That behavior is deprecated and if that case happens it will generate a deprecation warning. Set this flag to C(true) to suppress the deprecation warning. + - Please note that you will receive no further warning about this being removed until the module + will start failing in such cases from community.general 9.0.0 on. type: bool notes: From d814a28883de7e67e05f8c50053ace89de0c3d52 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:36:45 +1300 Subject: [PATCH 6/7] Update plugins/modules/web_infrastructure/django_manage.py Co-authored-by: Felix Fontein --- plugins/modules/web_infrastructure/django_manage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py index 44638b04f9d..2500e593ad1 100644 --- a/plugins/modules/web_infrastructure/django_manage.py +++ b/plugins/modules/web_infrastructure/django_manage.py @@ -118,6 +118,7 @@ - Please note that you will receive no further warning about this being removed until the module will start failing in such cases from community.general 9.0.0 on. type: bool + version_added: 5.8.0 notes: - C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter From 997c8099828c125fe7cf4c0c298adff58bd53196 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sun, 23 Oct 2022 22:39:38 +1300 Subject: [PATCH 7/7] minor change to help future removal of feature --- plugins/modules/web_infrastructure/django_manage.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py index 2500e593ad1..e6901be33ea 100644 --- a/plugins/modules/web_infrastructure/django_manage.py +++ b/plugins/modules/web_infrastructure/django_manage.py @@ -192,14 +192,12 @@ def _ensure_virtualenv(module): if venv_param is None: return - ack_venv_deprecation = module.params['ack_venv_creation_deprecation'] - vbin = os.path.join(venv_param, 'bin') activate = os.path.join(vbin, 'activate') if not os.path.exists(activate): # In version 9.0.0, if the venv is not found, it should fail_json() here. - if not ack_venv_deprecation: + if not module.params['ack_venv_creation_deprecation']: module.deprecate( 'The behavior of "creating the virtual environment when missing" is being ' 'deprecated and will be removed in community.general version 9.0.0. '