Using variables in handler's name and listen parameters

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