Issue 1:
Issue Type:

Bug Report

Ansible Version:

ansible 1.6.2

Environment:

OS X 10.9.3

Summary:

Notification is executed when task was not changed.

This behaviour occurs only on ansible 1.6.2 - earlier versions are ok.

Steps To Reproduce:

Simple play:

tasks:

- name: write /etc/ntp

copy: src=ntp.conf dest=/etc/ntp.conf owner=root group=root mode=0644

notify: restart ntp

handlers:

- name: restart ntp

service: name=ntp state=restarted

Two hosts: c01, c02. File /etc/ntp.conf is different than source on c01.

Expected Results:

TASK: [write /etc/ntp] ********************************************************

ok: [c02]

changed: [c01]

NOTIFIED: [restart ntp] *******************************************************

changed: [c01]

PLAY RECAP ********************************************************************

c01 : ok=3 changed=2 unreachable=0 failed=0

c02 : ok=2 changed=0 unreachable=0 failed=0

Actual Results:

TASK: [write /etc/ntp] ********************************************************

ok: [c02]

changed: [c01]

NOTIFIED: [restart ntp] *******************************************************

changed: [c01]

changed: [c02]

PLAY RECAP ********************************************************************

c01 : ok=3 changed=2 unreachable=0 failed=0

c02 : ok=3 changed=1 unreachable=0 failed=0

Issue 2:
Issue Type:

Bug Report

Ansible Version:

ansible 1.6.2

Environment:

Running from OS X 10.9.3

Managing RHEL 6.5, Fedora 20

Summary:

When a change is detected in a specific host handlers run on every host, even in ones without changes

@drybjed confirmed this bug and told me it is not present in 1.6.0 and it is related to this issue and commit

Steps To Reproduce:

Run a playbook like this:

---
- name: all hosts
hosts: all
user: root

tasks:
- name: foo
copy: src=/tmp/foo.conf dest=/tmp/foo.conf owner=root group=root mode=0644
notify:
- restart ntpd
handlers:
- include: "../../handlers/restart_services.yml"

Expected Results:

handlers run only on notified hosts

Actual Results:

handlers run on every host in the playbook, even in ones without changes:

PLAY [all hosts] **************************************************************

GATHERING FACTS ***************************************************************
ok: [host1.domain]
ok: [host2.domain]
ok: [host3.domain]

TASK: [foo] *******************************************************************
ok: [host1.domain] => {"changed": false, "dest": "/tmp/foo.conf", "gid": 0, "group": "root", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "mode": "0644", "owner": "root", "path": "/tmp/foo.conf", "secontext": "unconfined_u:object_r:admin_home_t:s0", "size": 0, "state": "file", "uid": 0}
ok: [host2.domain] => {"changed": false, "dest": "/tmp/foo.conf", "gid": 0, "group": "root", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "mode": "0644", "owner": "root", "path": "/tmp/foo.conf", "secontext": "unconfined_u:object_r:admin_home_t:s0", "size": 0, "state": "file", "uid": 0}
changed: [host3.domain] => {"changed": true, "dest": "/tmp/foo.conf", "gid": 0, "group": "root", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "mode": "0644", "owner": "root", "secontext": "unconfined_u:object_r:admin_home_t:s0", "size": 0, "src": "/root/.ansible/tmp/ansible-tmp-1401171805.31-244401036446552/source", "state": "file", "uid": 0}

NOTIFIED: [restart ntpd] ******************************************************
changed: [host1.domain] => {"changed": true, "item": "", "name": "ntpd", "state": "started"}
changed: [host2.domain] => {"changed": true, "item": "", "name": "ntpd", "state": "started"}
changed: [host3.domain] => {"changed": true, "item": "", "name": "ntpd", "state": "started"}

host2.domain : ok=3 changed=1 unreachable=0 failed=0
host1.domain : ok=3 changed=1 unreachable=0 failed=0
host3.domain : ok=3 changed=2 unreachable=0 failed=0