From 711ae03845b9e456b64be4002ff9e907c9bbe593 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 22 Aug 2017 16:35:23 -0400 Subject: [PATCH] yum: fix reporting group changes in check_mode (#28331) --- lib/ansible/modules/packaging/os/yum.py | 15 +++++++++++++-- test/integration/targets/yum/tasks/yum.yml | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 1b57677dbd4..fbcd9dc7251 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -744,9 +744,20 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i continue pkg = package - #groups :( + # groups elif spec.startswith('@'): - # complete wild ass guess b/c it's a group + found = False + my = yum_base() + groups_list = my.doGroupLists() + for group in groups_list[0]: # list of the installed groups on the first index + spec_lower = spec.lower() + if spec_lower.endswith(group.name.lower()) or spec_lower.endswith(group.groupid.lower()): + found = True + break + + if found: + continue + pkg = spec # range requires or file-requires or pkgname :( diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 43b468d0a92..b5db19aa656 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -255,7 +255,7 @@ state: present register: yum_result -- name: verify nothing changed +- name: verify sos is installed assert: that: - "yum_result.rc == 0" @@ -269,6 +269,25 @@ - "'rc' in yum_result" - "'results' in yum_result" +- name: try to install the group again, with --check to check 'changed' + yum: + name: "@Development Tools" + state: present + check_mode: yes + register: yum_result + +- name: verify nothing changed + assert: + that: + - "not yum_result.changed" + +- name: verify yum module outputs + assert: + that: + - "'changed' in yum_result" + - "'msg' in yum_result" + - "'results' in yum_result" + - name: try to install non existing group yum: name: "@non-existing-group"