From f5df17ca516bcc52ee4ef778d79e27b0581aa6a6 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Thu, 11 Oct 2018 14:16:50 -0500 Subject: [PATCH] yum module properly check for None config_file (#46641) (#46820) * yum module properly check for None config_file (#46641) * yum module properly check for None config_file * add conf_file test cases to yum integration tests Signed-off-by: Adam Miller (cherry picked from commit fb6e91bf98bfda6474833fa4b80f84b1efc5b27b) * add changelog for 2.7 backport Signed-off-by: Adam Miller --- .../yum_bugfux_conf_file_none_type.yml | 3 +++ lib/ansible/modules/packaging/os/yum.py | 4 ++-- test/integration/targets/yum/tasks/yum.yml | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/yum_bugfux_conf_file_none_type.yml diff --git a/changelogs/fragments/yum_bugfux_conf_file_none_type.yml b/changelogs/fragments/yum_bugfux_conf_file_none_type.yml new file mode 100644 index 00000000000..d26b4a1531b --- /dev/null +++ b/changelogs/fragments/yum_bugfux_conf_file_none_type.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Fix yum module to properly check for empty conf_file value diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index dad69ef8722..572f5efc81d 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -1317,8 +1317,8 @@ class YumModule(YumDnf): if self.conf_file and os.path.exists(self.conf_file): self.yum_basecmd += ['-c', self.conf_file] - if repoq: - repoq += ['-c', self.conf_file] + if repoq: + repoq += ['-c', self.conf_file] if self.skip_broken: self.yum_basecmd.extend(['--skip-broken']) diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 54bad921597..6dc29cc73fa 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -120,6 +120,15 @@ that: - "yum_result is successful" +- name: install sos with state latest in check mode with config file param + yum: name=sos state=latest conf_file=/etc/yum.conf + check_mode: true + register: yum_result +- name: verify install sos with state latest in check mode with config file param + assert: + that: + - "yum_result is changed" + - name: install sos with state latest in check mode yum: name=sos state=latest check_mode: true @@ -145,6 +154,15 @@ that: - "not yum_result is changed" +- name: install sos with state latest idempotence with config file param + yum: name=sos state=latest + register: yum_result +- name: verify install sos with state latest idempotence with config file param + assert: + that: + - "not yum_result is changed" + + # Multiple packages - name: uninstall sos and bc yum: name=sos,bc state=removed