Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlers run on every host, even in ones without notified changes #7559

Closed
rmarchei opened this issue May 27, 2014 · 6 comments
Closed

Handlers run on every host, even in ones without notified changes #7559

rmarchei opened this issue May 27, 2014 · 6 comments
Labels
bug This issue/PR relates to a bug. P1 Priority 1 - Immediate Attention Required; Release Immediately After Fixed

Comments

@rmarchei
Copy link
Contributor

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  
@rmarchei rmarchei changed the title Handlers run in every host, even in ones without notified changes Handlers run on every host, even in ones without notified changes May 27, 2014
@mpdehaan
Copy link
Contributor

This is quite unacceptable to us, we're adding a test for this specific thing and will update the release ASAP when ready once confirmed.

@jimi-c
Copy link
Member

jimi-c commented May 27, 2014

Thanks, I've reproduced this and will work on a fix today.

jimi-c added a commit to jimi-c/ansible that referenced this issue May 27, 2014
Also adds an integration test to catch this bug in the future.

Fixes ansible#7559
@jimi-c
Copy link
Member

jimi-c commented May 27, 2014

I've created the above patch to address this issue, if you'd like to test it yourself. I'm continuing testing on this, and will merge it in as soon as my testing is complete.

@drybjed
Copy link
Contributor

drybjed commented May 27, 2014

Looks like patch works correctly. +1

@rmarchei
Copy link
Contributor Author

patch tested, everything works fine with it!

@jimi-c jimi-c closed this as completed in cfd8c68 May 27, 2014
@jimi-c
Copy link
Member

jimi-c commented May 27, 2014

Great, just merged this in. Please let us know if you have any further problems related to this issue. Thanks!

jimi-c added a commit that referenced this issue Jun 9, 2014
Also adds an integration test to catch this bug in the future.

Fixes #7559
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P1 Priority 1 - Immediate Attention Required; Release Immediately After Fixed
Projects
None yet
Development

No branches or pull requests

5 participants