Hi,

I am playing around with parametrized notifications (handler calls) and I have 
came to the following questions:

1/ Is it documented somewhere? I did not find anything about the subject in 
official 
docs only several issues on github (e.g. 
https://github.com/ansible/ansible/issues/4853#issuecomment-28719258). So 
please 
forgive me that I am only guessing.

2/ I have not found any valid reason to parametrize a notification with 
role variable only. Is there any? I am confused by this kind of behavior.

To be clear I am trying to notify a handler named client-handler-something 
and that something is stored as a variable. The task that notifies an 
appropriate handler may look as follows.

---
# roles/client/tasks/main.yml

- name: "notify client-handler"
  debug: 
    msg: "Handler: {{handler_name}}"
  changed_when: true
  notify:
    - "{{handler_name}}"


- name: "run client-handler immediately"
  meta: flush_handlers

If I pass the variable with the role, it works.

---
# playbook.yml
- roles:
  - { role: client, handler_name: something }

If I use set_fact or try to compute the value on the fly it does not.

---
# roles/client/tasks/main.yml

- set_fact:
    handler_name: "client-handler-{{client.type|default('none')}}"

- name: "notify client-handler"
  debug: 
    msg: "Handler: {{handler_name}}"
  changed_when: true
  notify:
    - "{{handler_name}}"

I would like to know why. I assume that this is a general concept which can 
be very useful and it does not have nothing to do with roles in my opinion.

Thanks for clarifying this for me.

Tomas

-- 
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/5fbc5d73-2d50-4f87-a8dd-d2d738d4bce8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to