Repository: ansible/ansible-modules-core

Issue:
apt update_cache creates "changed" since ansible 2.2
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
apt

##### ANSIBLE VERSION
ansible 2.2.0.0 (stable-2.2 b229898f80)

##### CONFIGURATION
none

##### OS / ENVIRONMENT
Debian 8 64bit

##### SUMMARY
In ansible 2.1.3.0 using the apt module with update_cache: yes created an "ok" when deb package was already installed.

In ansible 2.2.0.0 (stable-2.2 b229898f80) the same task is creating a "changed" because of update_cache.

##### STEPS TO REPRODUCE

```
- name: testing
  hosts: all
  become: True
  tasks:
    - name: testing apt module
      apt:
        name: nano
        state: present
        update_cache: yes
```

##### EXPECTED RESULTS
Expected an "ok" if package nano is already installed,


Output in ansible 2.1.3.0
```
ok: [ansible-debian] => {"cache_update_time": 1478206604, "cache_updated": true, "changed": false, "invocation": {"module_args": {"allow_unauthenticated": false, "autoremove": false, "cache_valid_time": null, "deb": null, "default_release": null, "dpkg_options": "force-confdef,force-confold", "force": false, "install_recommends": null, "name": "nano", "only_upgrade": false, "package": ["nano"], "purge": false, "state": "present", "update_cache": true, "upgrade": null}, "module_name": "apt"}}
```

##### ACTUAL RESULTS
Return "changed" even package nano is already been installed on the system.

Output in ansible 2.2.0.0
```
changed: [ansible-debian] => {
    "cache_update_time": 1478206867,
    "cache_updated": true,
    "changed": true,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "install_recommends": null,
            "name": "nano",
            "only_upgrade": false,
            "package": [
                "nano"
            ],
            "purge": false,
            "state": "present",
            "update_cache": true,
            "upgrade": null
        },
        "module_name": "apt"
    }
}

```



Discussion:
<!-- @sbrueseke: Thanks for filing this bug report! -->

@ansible ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->


Resolving patch:
diff --git a/packaging/os/apt.py b/packaging/os/apt.py
--- a/packaging/os/apt.py
+++ b/packaging/os/apt.py
@@ -938,12 +938,6 @@ def main():
             retvals['cache_updated'] = updated_cache
             # Store when the update time was last
             retvals['cache_update_time'] = updated_cache_time
-            # If the cache was updated and the general state change was set to
-            #  False make sure that the change in cache state is accurately
-            #  updated by setting the general changed state to the same as
-            #  the cache state.
-            if updated_cache and not retvals['changed']:
-                retvals['changed'] = updated_cache
 
             if success:
                 module.exit_json(**retvals)


Test patch: