From 828e33f4193500d48a71163d0042ed4cc5c34630 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Wed, 6 Jun 2018 03:52:43 -0400 Subject: [PATCH] Do not consider an empty version string as a version (#41044) When using an empty string as the version argument, the module would before attempt to run something akin to: pip install module=="" This changes the behavior to: pip install module Fixes #41043 --- lib/ansible/modules/packaging/language/pip.py | 2 +- test/integration/targets/pip/tasks/pip.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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