Repository: ansible/ansible

Issue:
package_facts module does not support check mode
<!---
Verify first that your issue/request is not already reported on GitHub.
THIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.
Also test if the latest release, and devel branch are affected too.
ALWAYS add information AFTER (OUTSIDE) these html comments.
Otherwise it may end up being automatically closed by our bot. -->

##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug Report

##### COMPONENT NAME
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path-->
package_facts module

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
ansible 2.5.2
  config file = /home/user/Devel/fluentd/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
```

##### CONFIGURATION
<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).-->
DEFAULT_ROLES_PATH(/home/user/Devel/fluentd/ansible.cfg) = [u'/home/user/Devel/']
HOST_KEY_CHECKING(/home/user/Devel/fluentd/ansible.cfg) = False

##### OS / ENVIRONMENT
<!--- Mention, BELOW THIS COMMENT, the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.-->
RHEL7


##### SUMMARY
<!--- Explain the problem briefly -->
Unable to use dry run with package_facts module

skipping: [localhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "manager": "rpm"
        }
    },
    "msg": "remote module (package_facts) does not support check mode"
}



##### STEPS TO REPRODUCE
<!--- For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used. -->
run playbook with --check


##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
dry run works with module


##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```skipping: [localhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "manager": "rpm"
        }
    },
    "msg": "remote module (package_facts) does not support check mode"
}
```


Discussion:
Files identified in the description:
* [lib/ansible/modules/packaging/os/package_facts.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/package_facts.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/lib/ansible/modules/packaging/os/package_facts.py b/lib/ansible/modules/packaging/os/package_facts.py
--- a/lib/ansible/modules/packaging/os/package_facts.py
+++ b/lib/ansible/modules/packaging/os/package_facts.py
@@ -192,7 +192,7 @@ def apt_package_list():
 # FIXME: add more listing methods
 def main():
     global module
-    module = AnsibleModule(argument_spec=dict(manager=dict()))
+    module = AnsibleModule(argument_spec=dict(manager=dict()), supports_check_mode=True)
     manager = module.params['manager']
     packages = {}
     results = {}
diff --git a/lib/ansible/modules/system/service_facts.py b/lib/ansible/modules/system/service_facts.py
--- a/lib/ansible/modules/system/service_facts.py
+++ b/lib/ansible/modules/system/service_facts.py
@@ -192,7 +192,7 @@ def gather_services(self):
 
 
 def main():
-    module = AnsibleModule(argument_spec=dict())
+    module = AnsibleModule(argument_spec=dict(), supports_check_mode=True)
     service_modules = (ServiceScanService, SystemctlScanService)
     all_services = {}
     incomplete_warning = False


Test patch: