Hi Johan, with which version of Ansible are you seeing this?

James Cammarata
Director, Ansible Core Engineering
github: jimi-c

On Tue, Dec 8, 2015 at 9:42 AM, Johan Söderberg <joh...@gmail.com> wrote:

> Hi,
>
> I have a problem where handlers not being played. I've narrowed it down to
> the following situation:
>
> test.yml:
> ---
> - hosts: test
>   roles:
>    - role: common
>      when: commonrole_has_run is not defined
>
> roles/common/tasks/main.yml
> ---
> - name: Debug common role
>   shell: date
>   notify:
>     - debug_handler
>   tags: debug
>
> - set_fact: commonrole_has_run=true
>   when: commonrole_has_run is not defined
>
> roles/common/handlers/main.yml
> ---
> - name: debug_handler
>   debug: msg="debug_handler"
>   tags: debug
>
> When I run the playbook test.yml:
> PLAY [test]
> *******************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [tst01-adm.example.com]
>
> TASK: [common | Debug common role]
> ********************************************
> changed: [tst01-adm.example.com]
>
> TASK: [common | set_fact commonrole_has_run=true]
> *****************************
> ok: [tst01-adm.example.com]
>
> NOTIFIED: [common | debug_handler]
> ********************************************
> skipping: [tst01-adm.example.com]
>
> PLAY RECAP
> ********************************************************************
> tst01-adm.example.com : ok=3    changed=1    unreachable=0    failed=0
>
>
> Now if I remove the set_fact from roles/common/tasks/main.yml the handler
> is run:
>
> PLAY [test]
> *******************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [tst01-adm.example.com]
>
> TASK: [common | Debug common role]
> ********************************************
> changed: [tst01-adm.example.com]
>
> NOTIFIED: [common | debug_handler]
> ********************************************
> ok: [tst01-adm.example.com] => {
>     "msg": "debug_handler"
> }
>
> PLAY RECAP
> ********************************************************************
> tst01-adm.example.com : ok=3    changed=1    unreachable=0    failed=0
>
>
> I hope someone can shed some light why the handler is not being played?
> The reason for the set_fact is to avoid the common role being run more than
> once in a larger site with lots of roles.
>
> Thanks in advance,
>
> /Johan Söderberg
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/444545b9-0a0e-4ccd-891c-bfef2781b735%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/444545b9-0a0e-4ccd-891c-bfef2781b735%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMFyvFgra8VZ7v2YHpCOafLcx_uwrTirWQwTD6ru9L4Fe5tO_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to