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

handler+include triggered multiple times #18178

Closed
duck-rh opened this issue Oct 25, 2016 · 8 comments
Closed

handler+include triggered multiple times #18178

duck-rh opened this issue Oct 25, 2016 · 8 comments
Assignees
Labels
affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug.
Milestone

Comments

@duck-rh
Copy link

duck-rh commented Oct 25, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

handlers

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /home/duck/project/ansible.cfg
  configured module search path = Default w/o overrides

This is RC2.

CONFIGURATION

only the roles path is modified.

OS / ENVIRONMENT

Running on Debian unstable and managing CentOS 7.

SUMMARY

To chain multiple actions in a handler I include a file, and this leads to the handler being fired multiple times.

STEPS TO REPRODUCE

I used an include as suggested workaround for #14270.

My handler defined in handlers/main.yml:

- name: restart networkd
  include: apply_config.yml

The apply_config.yml file contains:

- name: reboot
  # workaround for https://github.com/ansible/ansible/issues/14413
  shell: "nohup bash -c 'sleep 2 && shutdown -r now' &"
  async: 0
  poll: 0
  ignore_errors: true

- name: waiting for server to be up
  local_action:
    module: wait_for
    host: "{{ ansible_host | default(inventory_hostname) }}"
    port: 22
    state: started
    delay: 5
    timeout: 600
  become: no

# ensure the facts are updated
- setup:
EXPECTED RESULTS

Several changes (during roles tasks) call this trigger, but it should only be executed once.

ACTUAL RESULTS

As you can see it is executed 5 times and breaks playbook execution:

TASK [networkd : enable networkd] **********************************************
changed: [myhost.mydom.tld]

RUNNING HANDLER [networkd : reboot] ********************************************
fatal: [myhost.mydom.tld]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
fatal: [myhost.mydom.tld]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
fatal: [myhost.mydom.tld]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
changed: [myhost.mydom.tld]
fatal: [myhost.mydom.tld]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}

RUNNING HANDLER [networkd : waiting for server to be up] ***********************
ok: [myhost.mydom.tld -> 192.168.57.10]
ok: [myhost.mydom.tld -> 192.168.57.10]
ok: [myhost.mydom.tld -> 192.168.57.10]
ok: [myhost.mydom.tld -> 192.168.57.10]
ok: [myhost.mydom.tld -> 192.168.57.10]

RUNNING HANDLER [networkd : setup] *********************************************
ok: [myhost.mydom.tld]
ok: [myhost.mydom.tld]
ok: [myhost.mydom.tld]
ok: [myhost.mydom.tld]
ok: [myhost.mydom.tld]
        to retry, use: --limit @/home/duck/OSAS/community-cage-infra-ansible/playbooks/deploy.retry
@ansibot ansibot added bug_report affects_2.2 This issue/PR affects Ansible v2.2 labels Oct 25, 2016
@shea851
Copy link

shea851 commented Dec 16, 2016

Same here. Anyone have a work-around? This was working fine in 2.0.

@jimi-c
Copy link
Member

jimi-c commented Dec 22, 2016

Hi @duck-rh, I'm having trouble reproducing this. Can you (or anyone else seeing this issue) give a full/simple example which reproduces this for you?

@jimi-c jimi-c added the needs_info This issue requires further information. Please answer any outstanding questions. label Dec 22, 2016
@jimi-c jimi-c self-assigned this Dec 22, 2016
@boernd
Copy link

boernd commented Jan 4, 2017

Hi @jimi-c

https://github.com/boernd/ansible-18178

Tested with 2.2.0 and latest 2.2.1 rc

> ansible-playbook test.yml -c localhost
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available


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

TASK [test : task one] *********************************************************
changed: [localhost]

TASK [test : task two] *********************************************************
changed: [localhost]

TASK [test : task three] *******************************************************
changed: [localhost]

RUNNING HANDLER [test : execute handler logic] *********************************
changed: [localhost]
changed: [localhost]
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=6    unreachable=0    failed=0   
> cat /tmp/ansible-18178 
task one
task two
task three
executing handler logic
executing handler logic
executing handler logic

@jimi-c jimi-c removed the needs_info This issue requires further information. Please answer any outstanding questions. label Feb 10, 2017
@alikins
Copy link
Contributor

alikins commented Feb 27, 2017

Attempting to reproduce this with the test role in #18178 (comment)

[fedora-25:ansible-18178 (master u=)]$ ansible-playbook  test.yml -c local
 [WARNING]: provided hosts list is empty, only localhost is available

[DEPRECATION WARNING]: Included file '/home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/handlerlogic.yml' not found, however since this include is not explicitly 
marked as 'static: yes', we will try and include it dynamically later. In the future, this will be an error unless 'static: no' is used on the include task. If you do not want missing includes 
to be considered dynamic, use 'static: yes' on the include or set the global ansible.cfg options to make all inclues static for tasks and/or handlers.
This feature will be removed in a future 
release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

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

TASK [test : task one] ****************************************************************************************************************************************************************************
changed: [localhost]

TASK [test : task two] ****************************************************************************************************************************************************************************
changed: [localhost]

TASK [test : task three] **************************************************************************************************************************************************************************
changed: [localhost]

RUNNING HANDLER [test : execute handler] **********************************************************************************************************************************************************
included: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/handlerlogic.yml for localhost

RUNNING HANDLER [test : command] ******************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ****************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=4    unreachable=0    failed=0   

[fedora-25:ansible-18178 (master u=)]$ cat /tmp/ansible-18178 
task one
task two
task three
executing handler logic

@alikins
Copy link
Contributor

alikins commented Feb 27, 2017

and with '-vvv' output:

[fedora-25:ansible-18178 (master u=)]$ ansible-playbook -vvv test.yml -c local
Using /home/adrian/.ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

[DEPRECATION WARNING]: Included file '/home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/handlerlogic.yml' not found, however since this include is not explicitly 
marked as 'static: yes', we will try and include it dynamically later. In the future, this will be an error unless 'static: no' is used on the include task. If you do not want missing includes 
to be considered dynamic, use 'static: yes' on the include or set the global ansible.cfg options to make all inclues static for tasks and/or handlers.
This feature will be removed in a future 
release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAYBOOK: test.yml ********************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [localhost] **********************************************************************************************************************************************************************************
META: ran handlers

TASK [test : task one] ****************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:2
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315 `" && echo ansible-tmp-1488219685.33-225925669884315="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmplF_Gu8 TO /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315/ /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488219685.33-225925669884315/" > /dev/null 2>&1 && sleep 0'
NOTIFIED HANDLER execute handler
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task one >> /tmp/ansible-18178", 
    "delta": "0:00:00.002755", 
    "end": "2017-02-27 13:21:25.452827", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task one >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:21:25.450072", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

TASK [test : task two] ****************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:6
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216 `" && echo ansible-tmp-1488219685.48-212450213583216="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpAhZilp TO /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216/ /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488219685.48-212450213583216/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task two >> /tmp/ansible-18178", 
    "delta": "0:00:00.002653", 
    "end": "2017-02-27 13:21:25.609334", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task two >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:21:25.606681", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

TASK [test : task three] **************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:10
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013 `" && echo ansible-tmp-1488219685.64-9820270750013="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp_Z6m5q TO /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013/ /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488219685.64-9820270750013/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task three >> /tmp/ansible-18178", 
    "delta": "0:00:00.002614", 
    "end": "2017-02-27 13:21:25.767810", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task three >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:21:25.765196", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

RUNNING HANDLER [test : execute handler] **********************************************************************************************************************************************************
included: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/handlerlogic.yml for localhost

RUNNING HANDLER [test : command] ******************************************************************************************************************************************************************
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344 `" && echo ansible-tmp-1488219685.81-196187363665344="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpVKWxUM TO /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344/ /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488219685.81-196187363665344/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo executing handler logic >> /tmp/ansible-18178", 
    "delta": "0:00:00.002784", 
    "end": "2017-02-27 13:21:25.935860", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo executing handler logic >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:21:25.933076", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}
META: ran handlers
META: ran handlers

PLAY RECAP ****************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=4    unreachable=0    failed=0   

[fedora-25:ansible-18178 (master u=)]$ cat /tmp/ansible-18178 
task one
task two
task three
executing handler logic

@alikins
Copy link
Contributor

alikins commented Feb 27, 2017

If I use the config option referenced obliquely in the deprecation blurb, I get:

[fedora-25:ansible-18178 (master % u=)]$ ANSIBLE_CONFIG=./ansible.cfg ansible-playbook test.yml -vvv -c local
Using ./ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

ERROR! the file_name '/home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/handlerlogic.yml' does not exist, or is not readable

If I fix up that path, then I see the handler run three times:

[fedora-25:ansible-18178 (master % u=)]$ git diff
diff --git roles/test/handlers/main.yml roles/test/handlers/main.yml
index 1bba1d2..4a099b1 100644
--- roles/test/handlers/main.yml
+++ roles/test/handlers/main.yml
@@ -1,3 +1,3 @@
 ---
 - name: execute handler
-  include: handlerlogic.yml
+  include: tasks/handlerlogic.yml
[fedora-25:ansible-18178 (master % u=)]$ rm -rf /tmp/ansible-18178 
[fedora-25:ansible-18178 (master % u=)]$ ANSIBLE_CONFIG=./ansible.cfg ansible-playbook test.yml -vvv -c local
Using ./ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

statically included: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/handlerlogic.yml

PLAYBOOK: test.yml ********************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [localhost] **********************************************************************************************************************************************************************************
META: ran handlers

TASK [test : task one] ****************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:2
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222 `" && echo ansible-tmp-1488220105.15-234953080045222="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpffdvyi TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.15-234953080045222/" > /dev/null 2>&1 && sleep 0'
NOTIFIED HANDLER test : execute handler logic
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task one >> /tmp/ansible-18178", 
    "delta": "0:00:00.002378", 
    "end": "2017-02-27 13:28:25.277643", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task one >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:25.275265", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

TASK [test : task two] ****************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:6
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574 `" && echo ansible-tmp-1488220105.31-143148350869574="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpt2Vzsg TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.31-143148350869574/" > /dev/null 2>&1 && sleep 0'
NOTIFIED HANDLER test : execute handler logic
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task two >> /tmp/ansible-18178", 
    "delta": "0:00:00.002467", 
    "end": "2017-02-27 13:28:25.430628", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task two >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:25.428161", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

TASK [test : task three] **************************************************************************************************************************************************************************
task path: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/main.yml:10
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399 `" && echo ansible-tmp-1488220105.46-167279132349399="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpvhBMO_ TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.46-167279132349399/" > /dev/null 2>&1 && sleep 0'
NOTIFIED HANDLER test : execute handler logic
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo task three >> /tmp/ansible-18178", 
    "delta": "0:00:00.002525", 
    "end": "2017-02-27 13:28:25.583769", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo task three >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:25.581244", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}

RUNNING HANDLER [test : execute handler logic] ****************************************************************************************************************************************************
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648 `" && echo ansible-tmp-1488220105.61-162287335373648="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpQuWfPf TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.61-162287335373648/" > /dev/null 2>&1 && sleep 0'
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146 `" && echo ansible-tmp-1488220105.77-90591752464146="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp1xMojV TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.77-90591752464146/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo executing handler logic >> /tmp/ansible-18178", 
    "delta": "0:00:00.002743", 
    "end": "2017-02-27 13:28:25.899937", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo executing handler logic >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:25.897194", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo executing handler logic >> /tmp/ansible-18178", 
    "delta": "0:00:00.002533", 
    "end": "2017-02-27 13:28:25.741808", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo executing handler logic >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:25.739275", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}
Using module file /home/adrian/src/ansible/lib/ansible/modules/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adrian
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814 `" && echo ansible-tmp-1488220105.93-27844617569814="` echo /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmprICmFB TO /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814/ /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814/command.py; rm -rf "/home/adrian/.ansible/tmp/ansible-tmp-1488220105.93-27844617569814/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": "echo executing handler logic >> /tmp/ansible-18178", 
    "delta": "0:00:00.002436", 
    "end": "2017-02-27 13:28:26.050072", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo executing handler logic >> /tmp/ansible-18178", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2017-02-27 13:28:26.047636", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "", 
    "stdout_lines": []
}
META: ran handlers
META: ran handlers

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

[fedora-25:ansible-18178 (master % u=)]$ cat /tmp/ansible-18178 
task one
task two
task three
executing handler logic
executing handler logic
executing handler logic

@alikins
Copy link
Contributor

alikins commented Feb 27, 2017

Adding a 'static: no' to the include in the handler seems to work.

roles/test/handlers/main.yml

---
- name: execute handler
  include: tasks/handlerlogic.yml
  static: no
[fedora-25:ansible-18178 (master % u=)]$ rm -rf /tmp/ansible-18178
[fedora-25:ansible-18178 (master % u=)]$ ansible-playbook test.yml 
 [WARNING]: provided hosts list is empty, only localhost is available


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

TASK [test : task one] ****************************************************************************************************************************************************************************
changed: [localhost]

TASK [test : task two] ****************************************************************************************************************************************************************************
changed: [localhost]

TASK [test : task three] **************************************************************************************************************************************************************************
changed: [localhost]

RUNNING HANDLER [test : execute handler] **********************************************************************************************************************************************************
included: /home/adrian/src/ansible-bug-repro/handlers_multiple_calls_15365/ansible-18178/roles/test/tasks/handlerlogic.yml for localhost

RUNNING HANDLER [test : command] ******************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ****************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=4    unreachable=0    failed=0   

[fedora-25:ansible-18178 (master % u=)]$ cat /tmp/ansible-18178
task one
task two
task three
executing handler logic

@jimi-c
Copy link
Member

jimi-c commented Apr 4, 2017

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 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
affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

8 participants