ansible/ansible-modules-core — pull request #264 by jfchevrette (2014-11-03 18:09:52+00:00)
Title: yum module: add support for check_mode /w yum package groups

Currently, when using check_mode with a yum package group (@group), ansible will return changed=True all the time. This is inconvenient when running in check_mode to see if your hosts configs are proper. In my use case, I have a playbook that I run in check_mode every morning and an email report is sent if I have any non-compliant hosts/tasks. (changed != 0)

This pull request adds check_mode support for package groups with state=installed or state=latest

Checking for package removal is tricky and I have not found a clean way to implement this. Ideas are welcome.

There is no way to ask yum or repoquery directly if a package group has installable packages or updateable packages. The way this is implemented is by expanding the package group using 'repoquery' and by passing the list of packages to is_installed which will return wether or not it has any packages that would be installed. Since repoquery will list ALL member packages even though they are excluded in yum.conf, there is a need to use both is_installed and is_available to ensure we only check for those packages yum would normally install (taking into account the excluded ones)