diff --git a/lib/ansible/modules/packaging/language/pip.py b/lib/ansible/modules/packaging/language/pip.py index 19665e8f13..40bd64ffb2 100644 --- a/lib/ansible/modules/packaging/language/pip.py +++ b/lib/ansible/modules/packaging/language/pip.py @@ -219,7 +219,7 @@ def _get_cmd_options(module, cmd): def _get_full_name(name, version=None): - if version is None: + if version is None or version == "": resp = name else: resp = name + '==' + version diff --git a/test/integration/targets/pip/tasks/pip.yml b/test/integration/targets/pip/tasks/pip.yml index 05af8b8d7a..3ae796fe6d 100644 --- a/test/integration/targets/pip/tasks/pip.yml +++ b/test/integration/targets/pip/tasks/pip.yml @@ -256,3 +256,17 @@ assert: that: - not pip_install_empty.changed + +# https://github.com/ansible/ansible/issues/41043 +- name: do not consider an empty string as a version + pip: + name: q + state: present + version: "" + virtualenv: "{{ output_dir }}/pipenv" + register: pip_install_empty_version_string + +- name: ensure that task installation did not fail + assert: + that: + - pip_install_empty_version_string is successful