Hi,
xou can write a handler for every single Action, and notify all desired 
handlers when needed. Handlers are executed in the order inside the 
handlers list.

theoretical example:

tasks:
   - name: change config
     action: do something
     notify:
      - enable_handler
      - reload_handler
      - start_handler
     

handlers:
   - name: reload_handler
     service: name=daemon state=reloaded
   - name: enable_handler
     service: name=daemon enabled=yes
   - name: start_handler
     service: name=daemon state=restarted   


=> the handlers are executed in the order of the handlers list as reload .. 
enable .. start independend of the order in the notify list. ;-)

Cheers 
     Ulli

Am Mittwoch, 11. November 2015 19:41:34 UTC+1 schrieb Dylan Martin:
>
> Hi all, I have a strange one that I hope you can help me with.
>
> I'm trying to make a role for systemd service unit files.  This is the 
> newfangled replacement for good ol' sysV init scripts in Rhel7, any recent 
> Fedora and a lot of other linux distros.
>
> The workflow is supposed to go something like this.
>
> 1) edit/install a unit file, like /etc/systemd/system/myservice.service
> 2) run systemctl daemon-reload 
> 3) run systemctl enable myservice
> 4) run systemctl start myservice
>
> daemon-reload tells the systemd daemon to re-read the unit files so it 
> will know you changed something
>
> In ansible, I interpret that as looking like
>
> 1) template out unit file
> 2) notify daemon-reload handler if unit file changed
> 3) service enable=true state=started name=myservice
>
> The problem is, if I've changed the unit file, the daemon-reload runs 
> after the service enable/start, so systemd doesn't know to re-read the unit 
> file before trying to start/enable the service.
>
> I could just make it run daemon-reload every time the role runs, which 
> kindof sucks.  Also, if I'm installing a boatload of unit files, I'd like 
> to do a daemon-reload only once to get them all.  I could make the 
> daemon-reload a normal task that only runs when the template changes, but 
> that means I'd be running the daemon-reload once for every unit file, which 
> sucks in the case where I'm installing a boatload of them.  I looked at 
> post_task, but that's not for roles.  
>
> Does anyone know a good way to do this?
>
> Thanks!
> -Dylan
>

-- 
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/db9d78e3-e188-4295-9765-b18ffb85c1d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to