# ansible-playbook doesn't run handlers if play has different tag

**URL:** <https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481>\
**Category:** Get Help\
**Tags:** role, playbook, ansible-core\
**Created:** [September 13, 2025, 6:09pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481 "2025-09-13T18:09:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alphabetical](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alphabetical/32/7570_2.png) [@alphabetical](https://forum.ansible.com/u/alphabetical)\
**Post date:** [September 13, 2025, 6:09pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/1 "2025-09-13T18:09:20Z")

</div>

I have encountered some unexpected ansible-playbook behavior with respect to play tags and role tags. I’m trying to understand if this is an Ansible bug or this is a limitation of using tags, so I followed the recommendation to ask in the forums first.

I am using tags in order to quickly run a single role without (1) running the other roles in the play and (2) running other plays in the same playbook. But I am finding that handlers are not executed when they should be executed.

Consider this simplified playbook (our playbooks have more plays and use more roles):

```auto
# site.yml
- hosts: all
  tags: [play1]
  roles:
    - role: role1
      tags: [role1]

```

When I run: `ansible-playbook site.yml -t role1` then:

- the tasks for role1 are executed (as expected)
- the changed tasks are shown as “changed” (as expected)
- **handlers for changed tasks aren’t shown or executed** (not expected)

The handlers are not even displayed in the ansible-playbook output as “skipped”, they simply don’t appear at all.

However, if I remove all tags from the play (in this case, just the tag `play1`), then the handlers for role1 are executed!

Versions:

- ansible `11.4.0` (core `2.19.2`)
- Python `3.13.2`

Here is the remaining code to support this example:

```auto
# roles/role1/tasks/main.yml
- name: Role 1 Task
  debug:
  changed_when: true
  notify:
    - Role 1 Handler

---

# roles/role1/handlers/main.yml
- name: Role 1 Handler
  debug:

```

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [September 13, 2025, 6:34pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/2 "2025-09-13T18:34:10Z")

</div>

> <https://github.com/ansible/ansible/issues/85475>
>
> \### Summary
> 
> In ansible 2.19, defining a play tag prevents role handlers from ex…ecuting. If you run the playbook with the role tag, notified handler is not executed.
> 
> This works well in ansible 2.18 (and before) and also when there are no \*play\* tags defined.
> 
> \### Issue Type
> 
> Bug Report
> 
> \### Component Name
> 
> core
> 
> \### Ansible Version
> 
> \`\`\`console
> $ ansible --version
> ansible \[core 2.19.0rc2\]
> config file = ~/projects/ansible-handlers-error/ansible.cfg
> configured module search path = \['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'\]
> ansible python module location = ~/.virtualenvs/ansible2.19/lib/python3.13/site-packages/ansible
> ansible collection location = ~/.ansible/collections:/usr/share/ansible/collections
> executable location = ~/.virtualenvs/ansible2.19/bin/ansible
> python version = 3.13.5 (main, Jun 25 2025, 18:55:22) \[GCC 14.2.0\] (~/.virtualenvs/ansible2.19/bin/python)
> jinja version = 3.1.6
> pyyaml version = 6.0.2 (with libyaml v0.2.5)
> \`\`\`
> 
> \### Configuration
> 
> \`\`\`console
> \# if using a version older than ansible-core 2.12 you should omit the '-t all'
> $ ansible-config dump --only-changed -t all
> ANSIBLE\_NOCOWS(~/projects/ansible-handlers-error/ansible.cfg) = True
> CONFIG\_FILE() = ~/projects/ansible-handlers-error/ansible.cfg
> EDITOR(env: EDITOR) = vim
> PAGER(env: PAGER) = less
> 
> GALAXY\_SERVERS:
> \`\`\`
> 
> \### OS / Environment
> 
> Debian 13 (testing)
> 
> \### Steps to Reproduce
> 
> 1. Use this \`playbook.yml\`:
> \`\`\`yaml
> - name: Test handler
> hosts: localhost
> roles:
> - name: foo
> tags:
> - foo
> tags:
> - broken
> \`\`\`
> 2. Use this role \`foo\`:
> \`tasks.yml\`:
> \`\`\`yaml
> - name: Ping
> ansible.builtin.ping:
> changed\_when: true
> notify: Handle this
> \`\`\`
> \`handler.yml\`:
> \`\`\`yaml
> - name: Handle this
> ansible.builtin.debug:
> msg: "Handler fired"
> \`\`\`
> 3. Run the playbook with the role tag:
> \`\`\`
> ansible-playbook -C -t foo playbook.yml
> \`\`\`
> 4. Handlers are not executed
> 
> \### Expected Results
> 
> \`\`\`console
> PLAY \[Test handler\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK \[broken : meta\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK \[broken : Ping\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> changed: \[localhost\]
> 
> RUNNING HANDLER \[broken : Handle this\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> ok: \[localhost\] =\> {
> "msg": "Handler fired"
> }
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> localhost : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
> \`\`\`
> 
> \### Actual Results
> 
> \`\`\`console
> PLAY \[Test handler\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK \[broken : meta\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK \[broken : Ping\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> changed: \[localhost\]
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
> \`\`\`
> 
> \### Code of Conduct
> 
> \- \[x\] I agree to follow the Ansible Code of Conduct

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [September 13, 2025, 6:36pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/3 "2025-09-13T18:36:10Z")

</div>

[Edit: @flowerysong saw the relevant bit. Nice work. I didn’t see your post when I started composing mine.]

I’m unable to reproduce your results, having tried to reproduce your given input playbook, role, and handler files. (Thanks, btw, for including all the files! That really helps us help you.)

Here’s my exact file contents, my playbook invocation, and results, copy-n-pasted from my terminal.

```txt
utoddl@tango:~/ansible/alphabetical$ while read f ; do printf "### %s ###\n" "$f" ; cat "$f" ; echo ; done < <(find . -type f)
### ./roles/role1/tasks/main.yml ###
---
# ./roles/role1/tasks/main.yml
- name: Role 1 Task
  ansible.builtin.debug:
  # msg: "role1/tasks/main.yml notifying 'Role 1 Handler'"
  changed_when: true
  notify:
    - Role 1 Handler

### ./roles/role1/handlers/main.yml ###
---
# ./roles/role1/handlers/main.yml
- name: Role 1 Handler
  ansible.builtin.debug:
    msg: "Role 1 Handler ran."

### ./site.yml ###
---
# ./site.yml
- name: Plays with roles and tags
  hosts: all
  tags: [play1]
  roles:
    - role: role1
      tags: [role1]

utoddl@tango:~/ansible/alphabetical$ ansible-playbook site.yml -i localhost, --tags role1

PLAY [Plays with roles and tags] *********************************************************************

TASK [role1 : Role 1 Task] ***************************************************************************
changed: [localhost] => {
    "msg": "Hello world!"
}

RUNNING HANDLER [role1 : Role 1 Handler] *************************************************************
ok: [localhost] => {
    "msg": "Role 1 Handler ran."
}

PLAY RECAP *******************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   

```

---

<div class="post-metadata">

**Author:** ![alphabetical](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alphabetical/32/7570_2.png) [@alphabetical](https://forum.ansible.com/u/alphabetical)\
**Post date:** [September 13, 2025, 8:19pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/4 "2025-09-13T20:19:06Z")

</div>

Thanks @flowerysong for linking to a bug report that is the exact issue I am seeing! From the issue, I can see that a fix is being implemented so I will look forward to that. Not sure if I should mark this discussion thread as resolved, or wait until the fix is out.

I also appreciate @utoddl trying to reproduce the issue. Could it be that your ansible core is at `2.18.x` or earlier ?

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [September 14, 2025, 12:43am UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/5 "2025-09-14T00:43:24Z")

</div>

> [@alphabetical](#):
>
> I also appreciate @utoddl trying to reproduce the issue. Could it be that your ansible core is at `2.18.x` or earlier ?

Yes, it is; 2.18.6 in fact.

Hope this issue gets resolved soon. Cheers!

---

<div class="post-metadata">

**Author:** ![alphabetical](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alphabetical/32/7570_2.png) [@alphabetical](https://forum.ansible.com/u/alphabetical)\
**Post date:** [November 16, 2025, 1:23pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/6 "2025-11-16T13:23:36Z")

</div>

I have retested with Ansible 12.2.0 [core 2.19.4] and it seems to be fixed!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 16, 2025, 1:23pm UTC](https://forum.ansible.com/t/ansible-playbook-doesnt-run-handlers-if-play-has-different-tag/44481/7 "2025-12-16T13:23:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
