You have a few issues, one you have already attempted to address.

1. Don't use `include` as it has behavior that cannot be easily reasoned
and understood in many cases
2. A change was made in Ansible 2.8 that is documented in the porting
guide, preventing you from using a static include or `import_tasks` as a
handler itself. This is described in more detail at
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html#imports-as-handlers

Effectively, what you need is to switch to `include_tasks`:

- name: restart prometheus
  include_tasks: roles/common/tasks/restart-service.yml
  vars:
    service_name: prometheus

On Mon, Jun 3, 2019 at 7:19 AM Jan-Philipp Bolle <[email protected]>
wrote:

> Hi,
>
>
> In my roles I use the following Handler definition:
>
>
> - name: restart prometheus
>   include: "roles/common/tasks/restart-service.yml
> service_name=prometheus"
>
>
>
> This works fine in 2.7.10.
>
>
> After updating to 2.8.0 I got the following error:
>
>> ERROR! The requested handler 'restart prometheus' was not found in either
>> the main handlers list nor in the listening handlers list
>
>
> I have tried several variants:
> - name: restart prometheus
>   import_tasks: roles/common/tasks/restart-service.yml
>   vars:
>     service_name: prometheus
>
>
>
> Same Problem.
>
>
> If I use a simple debug statement it works:
> - name: restart prometheus
>   debug:
>     msg: System {{ inventory_hostname }} has uuid {{ ansible_product_uuid
> }}
>
>
> I realize that you should avoid dependencies between roles but repeating a
> block of code over and over doesn't seem to be a good solution either.
>
>
> Any idea?
>
>
> Regards Philipp
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4eb2e371-d949-4ca4-a292-20faa1634803%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/4eb2e371-d949-4ca4-a292-20faa1634803%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-dqZspwmTSQ7ftUUth7%3D9KsLSkBVZjnHGaCTGoX0aeAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to