From 4fe7671d348fe34cb13f3532074173a0441158a2 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Thu, 11 Oct 2018 11:41:04 -0500 Subject: [PATCH] yum module handle list optional empty strings properly (#46634) (#46819) * yum module handle list optional empty strings properly (#46634) Fixes #46517 Signed-off-by: Adam Miller (cherry picked from commit ad405fc21e8f060b62c9f0095197946028feec68) * add changelog Signed-off-by: Adam Miller --- changelogs/fragments/yum_bugfux.yml | 3 +++ lib/ansible/module_utils/yumdnf.py | 3 +++ test/integration/targets/yum/tasks/yum.yml | 10 ++++++++++ 3 files changed, 16 insertions(+) create mode 100644 changelogs/fragments/yum_bugfux.yml diff --git a/changelogs/fragments/yum_bugfux.yml b/changelogs/fragments/yum_bugfux.yml new file mode 100644 index 0000000000..08cbc17c4a --- /dev/null +++ b/changelogs/fragments/yum_bugfux.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - fix yum module to handle list argument optional empty strings properly diff --git a/lib/ansible/module_utils/yumdnf.py b/lib/ansible/module_utils/yumdnf.py index aa3e0138a6..9fd5360c6e 100644 --- a/lib/ansible/module_utils/yumdnf.py +++ b/lib/ansible/module_utils/yumdnf.py @@ -110,6 +110,9 @@ class YumDnf(with_metaclass(ABCMeta, object)): some_list.extend(new_list) + if some_list == [""]: + return [] + return some_list @abstractmethod diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 52d58d8f96..54bad92159 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -83,6 +83,16 @@ that: - "not yum_result is changed" +- name: install sos again with empty string enablerepo + yum: name=sos state=present enablerepo="" + register: yum_result +- name: verify no change on third install with empty string enablerepo + assert: + that: + - "yum_result is success" + - "not yum_result is changed" + + # INSTALL AGAIN WITH LATEST - name: install sos again with state latest in check mode yum: name=sos state=latest