# Using variables in handler's name and listen parameters

**URL:** <https://forum.ansible.com/t/using-variables-in-handlers-name-and-listen-parameters/28583>\
**Category:** Ansible Project\
**Created:** [September 16, 2018, 9:22pm UTC](https://forum.ansible.com/t/using-variables-in-handlers-name-and-listen-parameters/28583 "2018-09-16T21:22:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Komail\_Kanjee](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@Komail\_Kanjee](https://forum.ansible.com/u/Komail_Kanjee)\
**Post date:** [September 16, 2018, 9:22pm UTC](https://forum.ansible.com/t/using-variables-in-handlers-name-and-listen-parameters/28583/1 "2018-09-16T21:22:25Z")

</div>

Hello,

I have a role which needs a dynamic handler.

I defined the handler in roles/foo/handlers/main.yml as:

- name: {{ item.name }}  
shell: docker restart {{ item.name }}  
listen: {{ item.name }}  
with\_items: “{{ config\_list }}”

When the task is notifying the handler I get the error:  
ERROR! The requested handler ‘name001’ was not found in either the main handlers list nor in the listening handlers list

1. Is my definition of the handler correct using with\_items?

2. How can I list listening handlers to see if the handler is even defined or not  
Thanks,

Komail
