Issue 1:
From @ahes on 2016-11-08T16:10:24Z

ISSUE TYPE

Bug Report

COMPONENT NAME

apt

ANSIBLE VERSION

ansible 2.2.0.0

CONFIGURATION

Default

OS / ENVIRONMENT

Debian Jessie 64 GNU/Linux

SUMMARY

When installing packages and using update_cache option apt module always returns state CHANGED even if packages are already installed.

In my opinion expected behavior would be:

when using update_cache AND installing package(s) return status CHANGED only when package has been installed or updated, no matter if cache has been updated or not.

when using update_cache without installing any package(s) return status CHANGED when cache has been updated.

STEPS TO REPRODUCE

---
- hosts: localhost
gather_facts: no
become: yes
tasks:
- apt:
name: htop
update_cache: yes

EXPECTED RESULTS

As in ansible 2.1:

PLAY [localhost] ***************************************************************

TASK [apt] *********************************************************************
ok: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0

Part of debug output:

ok: [localhost] => {"cache_update_time": 1478621386, "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": "htop", "only_upgrade": false, "package": ["htop"], "purge": false, "state": "present", "update_cache": true, "upgrade": null}, "module_name": "apt"}}

ACTUAL RESULTS

PLAY [localhost] ***************************************************************

TASK [apt] *********************************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0

Part of debug output:

changed: [localhost] => {
"cache_update_time": 1478621193,
"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": "htop",
"only_upgrade": false,
"package": [
"htop"
],
"purge": false,
"state": "present",
"update_cache": true,
"upgrade": null
},
"module_name": "apt"
}
}

Copied from original issue: ansible/ansible-modules-core#5532

Issue 2:
So I have some playbooks here: https://github.com/jsmartin/ansible-examples/tree/riak/riak

As you will see, notifies for 10.42.0.6 seem to be ocurring twice.

ansible-playbook -u vagrant site.yml -i ~/work/vms/ansible-riak/hosts -k
SSH password:

PLAY [riak_cluster] ***********************************************************

GATHERING FACTS ***************************************************************
ok: [10.42.0.7]
ok: [10.42.0.8]
ok: [10.42.0.6]

TASK: [update pam configuration] **********************************************
changed: [10.42.0.8]
changed: [10.42.0.6]
changed: [10.42.0.7]

TASK: [mount the riak volume with optmized settings] **************************
changed: [10.42.0.8]
changed: [10.42.0.7]
changed: [10.42.0.6]

TASK: [remount the partition] *************************************************
changed: [10.42.0.8]
changed: [10.42.0.6]
changed: [10.42.0.7]

TASK: [confgure rc.local] *****************************************************
changed: [10.42.0.6]
changed: [10.42.0.8]
changed: [10.42.0.7]

TASK: [create sysctl.d] *******************************************************
ok: [10.42.0.6]
ok: [10.42.0.8]
ok: [10.42.0.7]

TASK: [configure sysctl] ******************************************************
changed: [10.42.0.6]
changed: [10.42.0.7]
changed: [10.42.0.8]

TASK: [update system ulimit settings] *****************************************
ok: [10.42.0.7]
ok: [10.42.0.8]
ok: [10.42.0.6]

NOTIFIED: [update sysctl] *****************************************************
changed: [10.42.0.6]
changed: [10.42.0.7]
changed: [10.42.0.8]

NOTIFIED: [source rclocal] ****************************************************
changed: [10.42.0.8]
changed: [10.42.0.6]
changed: [10.42.0.7]

TASK: [group_by key={{ansible_distribution}}] *********************************
changed: [10.42.0.6]

NOTIFIED: [update sysctl] *****************************************************
changed: [10.42.0.6]

NOTIFIED: [source rclocal] ****************************************************
changed: [10.42.0.6]

PLAY [Ubuntu] *****************************************************************

TASK: [set the riak ulimit] ***************************************************
changed: [10.42.0.6]
changed: [10.42.0.7]
changed: [10.42.0.8]

TASK: [update pam configuration] **********************************************
changed: [10.42.0.8] => (item=/etc/pam.d/common-session)
changed: [10.42.0.6] => (item=/etc/pam.d/common-session)
changed: [10.42.0.7] => (item=/etc/pam.d/common-session)
changed: [10.42.0.8] => (item=/etc/pam.d/common-session-noninteractive)
changed: [10.42.0.6] => (item=/etc/pam.d/common-session-noninteractive)
changed: [10.42.0.7] => (item=/etc/pam.d/common-session-noninteractive)

TASK: [get the basho apt key] *************************************************
changed: [10.42.0.8]
changed: [10.42.0.6]
changed: [10.42.0.7]

TASK: [configure the basho repository] ****************************************
changed: [10.42.0.6]
changed: [10.42.0.8]
changed: [10.42.0.7]

TASK: [install riak] **********************************************************
changed: [10.42.0.6]
changed: [10.42.0.8]
changed: [10.42.0.7]

TASK: [configure iptables] ****************************************************
changed: [10.42.0.7]
changed: [10.42.0.6]
changed: [10.42.0.8]

NOTIFIED: [restore iptables] **************************************************
changed: [10.42.0.8]
changed: [10.42.0.6]
changed: [10.42.0.7]

NOTIFIED: [restore iptables] **************************************************
changed: [10.42.0.6]

PLAY [CentOS] *****************************************************************
skipping: no hosts matched

PLAY [riak_cluster] ***********************************************************

TASK: [configure app.config] **************************************************
changed: [10.42.0.6]
changed: [10.42.0.8]
changed: [10.42.0.7]

TASK: [configure vm.args] *****************************************************
changed: [10.42.0.6]
changed: [10.42.0.7]
changed: [10.42.0.8]

TASK: [start riak] ************************************************************
changed: [10.42.0.7]
changed: [10.42.0.6]
changed: [10.42.0.8]

TASK: [wait for port to become active] ****************************************
ok: [10.42.0.7]
ok: [10.42.0.6]
ok: [10.42.0.8]

TASK: [wait for riak_kv service to start] *************************************
ok: [10.42.0.8]
ok: [10.42.0.6]
ok: [10.42.0.7]

NOTIFIED: [restart riak] ******************************************************
changed: [10.42.0.7]
changed: [10.42.0.8]
changed: [10.42.0.6]

NOTIFIED: [wait for http] *****************************************************
ok: [10.42.0.8]
ok: [10.42.0.6]
ok: [10.42.0.7]

NOTIFIED: [wait for kv] *******************************************************
ok: [10.42.0.7]
ok: [10.42.0.6]
ok: [10.42.0.8]

NOTIFIED: [restart riak] ******************************************************
changed: [10.42.0.6]

NOTIFIED: [wait for http] *****************************************************
ok: [10.42.0.6]

NOTIFIED: [wait for kv] *******************************************************
ok: [10.42.0.6]

PLAY [riak_cluster] ***********************************************************

TASK: [Create a group based on riak node type.] *******************************
changed: [10.42.0.6]

TASK: [collect riak facts] ****************************************************
ok: [10.42.0.8]
ok: [10.42.0.6]
ok: [10.42.0.7]

PLAY [middle:last] ************************************************************

TASK: [debug msg='primary {{hostvars[groups['primary'][0]]['riak_outputs']['node_name']}}'] ***
ok: [10.42.0.7]
ok: [10.42.0.8]

TASK: [join riak cluster] *****************************************************
changed: [10.42.0.8]
changed: [10.42.0.7]

PLAY [last] *******************************************************************

TASK: [plan cluster changes] **************************************************
changed: [10.42.0.8]

NOTIFIED: [commit cluster changes] ********************************************
<job 374120038072> polling, 590s remaining
<job 374120038072> polling, 580s remaining
<job 374120038072> polling, 570s remaining
<job 374120038072> polling, 560s remaining
<job 374120038072> polling, 550s remaining
<job 374120038072> polling, 540s remaining
<job 374120038072> polling, 530s remaining
ok: [10.42.0.8]
<job 374120038072> finished on 10.42.0.8

PLAY RECAP ********************************************************************
10.42.0.6 : ok=34 changed=24 unreachable=0 failed=0
10.42.0.7 : ok=30 changed=21 unreachable=0 failed=0
10.42.0.8 : ok=33 changed=22 unreachable=0 failed=0