From b4734a956cdb4a08eb37b22d1fb757a1ead96efb Mon Sep 17 00:00:00 2001 From: Davide Sbetti Date: Sat, 30 Sep 2023 11:39:55 +0200 Subject: [PATCH] Revert potential incorrect fix for forcereinstall, add changelog fragment --- ...815-fix-pip-changed-status-vcs-install.yml | 2 ++ lib/ansible/modules/pip.py | 4 +-- test/integration/targets/pip/tasks/pip.yml | 25 ------------------- 3 files changed, 4 insertions(+), 27 deletions(-) create mode 100644 changelogs/fragments/81815-fix-pip-changed-status-vcs-install.yml diff --git a/changelogs/fragments/81815-fix-pip-changed-status-vcs-install.yml b/changelogs/fragments/81815-fix-pip-changed-status-vcs-install.yml new file mode 100644 index 00000000000..5d74b964812 --- /dev/null +++ b/changelogs/fragments/81815-fix-pip-changed-status-vcs-install.yml @@ -0,0 +1,2 @@ +bugfixes: + - pip - Incorrect changed status was returned in case of installation from VCS where the target commit was different but the version was the same. The fix now evaluates also the commits used for installation from VCS (https://github.com/ansible/ansible/issues/81751). \ No newline at end of file diff --git a/lib/ansible/modules/pip.py b/lib/ansible/modules/pip.py index f2222b89f9b..ca80e90ff21 100644 --- a/lib/ansible/modules/pip.py +++ b/lib/ansible/modules/pip.py @@ -800,7 +800,7 @@ def main(): ) if module.check_mode: - if extra_args or requirements or state == 'latest' or not name or state == "forcereinstall": + if extra_args or requirements or state == 'latest' or not name: module.exit_json(changed=True) pkg_cmd, out_pip, err_pip = _get_packages(module, pip, chdir) @@ -850,7 +850,7 @@ def main(): changed = 'Successfully installed' in out_pip else: dummy, out_freeze_after, dummy = _get_packages(module, pip, chdir) - changed = out_freeze_before != out_freeze_after or state == "forcereinstall" + changed = out_freeze_before != out_freeze_after changed = changed or venv_created diff --git a/test/integration/targets/pip/tasks/pip.yml b/test/integration/targets/pip/tasks/pip.yml index 93fdd603171..6b3a320c1b5 100644 --- a/test/integration/targets/pip/tasks/pip.yml +++ b/test/integration/targets/pip/tasks/pip.yml @@ -63,31 +63,6 @@ - command: "{{ ansible_python.executable }} -c 'import {{ item }}'" loop: '{{ pip_test_modules }}' -# force reinstall packages in check mode and ensure we recorded a change -- name: forcereinstall packages in check mode - pip: - name: "{{ pip_test_packages }}" - state: forcereinstall - check_mode: true - register: forcereinstall_result_check_mode - -- name: verify we recorded a change - assert: - that: - - "forcereinstall_result_check_mode is changed" - -# force reinstall packages for real and ensure we recorded a change -- name: forcereinstall packages - pip: - name: "{{ pip_test_packages }}" - state: forcereinstall - register: forcereinstall_result - -- name: verify we recorded a change - assert: - that: - - "forcereinstall_result is changed" - # now remove it to test uninstallation of a package we are sure is installed - name: now uninstall so we can see that a change occurred