Repository: ansible/ansible

Issue:
 [WARNING]: Removed unexpected internal key in module return: _ansible_verbose_override = True
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
Gathering Facts

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
$ ansible --version
ansible 2.3.0 (devel b2a16379c8) last updated 2017/01/17 23:05:35 (GMT -500)
  config file = /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
Using ansible/examples/ansible.cfg ansible.cfg

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->

##### SUMMARY
<!--- Explain the problem briefly -->
Getting warning messages for Gathering Facts

##### 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.
-->
Doesn't matter the play, Gather Facts throws the warning.

<!--- Paste example playbooks or commands between quotes below -->
```yaml

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
No warning when Gathering Facts

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
Using module file /Users/tanner/projects/ansible.git/ansible/lib/ansible/modules/system/setup.py
<crashplan-3.XXX> ESTABLISH SSH CONNECTION FOR USER: ansible
<crashplan-3.XXX> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/tanner/.ansible/cp/ansible-ssh-%h-%p-%r crashplan-3.XXX '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1484716829.46-198379160695029 `" && echo ansible-tmp-1484716829.46-198379160695029="` echo ~/.ansible/tmp/ansible-tmp-1484716829.46-198379160695029 `" ) && sleep 0'"'"''
 [WARNING]: Removed unexpected internal key in module return:
_ansible_verbose_override = True
 [WARNING]: Removed unexpected internal key in module return:
_ansible_verbose_override = True
 [WARNING]: Removed unexpected internal key in module return:
_ansible_verbose_override = True
```



Discussion:
cc @risaacson
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
+1


    # ansible --version
    ansible 2.3.0 (devel a3321d1074) last updated 2017/01/18 15:37:55 (GMT +200)
      config file = /etc/ansible/ansible.cfg
      configured module search path = [u'/etc/ansible/library']


Resolving patch:
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -3915,9 +3915,6 @@ def get_all_facts(module):
         if module.params['filter'] == '*' or fnmatch.fnmatch(k, module.params['filter']):
             setup_result['ansible_facts'][k] = v
 
-    # hack to keep --verbose from showing all the setup module results
-    setup_result['_ansible_verbose_override'] = True
-
     return setup_result
 
 # Allowed fact subset for gather_subset options and what classes they use
diff --git a/lib/ansible/plugins/action/normal.py b/lib/ansible/plugins/action/normal.py
--- a/lib/ansible/plugins/action/normal.py
+++ b/lib/ansible/plugins/action/normal.py
@@ -31,14 +31,9 @@ def run(self, tmp=None, task_vars=None):
         # remove as modules might hide due to nolog
         del results['invocation']['module_args']
         results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
-        # Remove special fields from the result, which can only be set
-        # internally by the executor engine. We do this only here in
-        # the 'normal' action, as other action plugins may set this.
-        #
-        # We don't want modules to determine that running the module fires
-        # notify handlers.  That's for the playbook to decide.
-        for field in ('_ansible_notify',):
-            if field in results:
-                results.pop(field)
+
+        # hack to keep --verbose from showing all the setup module results
+        if self._task.action == 'setup':
+            results['_ansible_verbose_override'] = True
 
         return results


Test patch: