Kai Stian Olstad wrote:
> On 12. feb. 2017 18:47, Michael Ströder wrote:
>> Kai Stian Olstad wrote:
>>> On 12. feb. 2017 17:56, Michael Ströder wrote:
>>>> But some updates might also require restart of a service managed in a 
>>>> subsequently
>>>> invoked role which does not receive the notifications.
>>>> (In puppet I'd simply _subscribe_ to the resource to "pull" the 
>>>> notification.)
>>>>
>>>> How to handle this case in ansible?
>>>
>>> Ansible doesn't have something like subscribe so you'll have to use notify.
>>> But you can notify a handler in another role since they are global.
>>
>> But then a role has to know the handler names in the other role which 
>> somewhats
>> contradicts the concept of modular design.
> 
> The same challenge you have with subscribe in Puppet, you'll need to use the 
> other
> resources name.

Yes. But the resource name would be the OS package's name which the relevant 
roles would
know anyway. (I'm not a puppet fan though.)

> You can always create the handler in the role so you don't need to use the 
> other roles
> handler, that's what I do to make them independent.

I'll try explain better.

Assume a play invoking two roles A and B:

role A
  - installs pkg1 with notifying "restart srv1" in case of a package update
  - enables and initially starts service srv1
  - has handler "restart srv1" which restarts service srv1

role B
  - installs *pkg1* with notifying "restart srv2" in case of a package update
  - enables and initially starts service srv2
  - has handler "restart srv2" which restarts service srv2

When role A gets played the handler "restart srv1" will receive the 
notification of pkg1
update but in role B there will be no such pkg1 update anymore and thus no 
notification
to handler "restart srv2" and therefore srv2 continous to run based on outdated 
software
(which I'd like to avoid).

Or can I have handlers with same name "restart srv1 and srv2" in more than role 
and all
gets notified?

Ciao, Michael.


-- 
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/2a9d3671-26f9-a9f1-ba60-4affd422d07d%40stroeder.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to