Lets say I have a playbook, where I want to add a line to the file /etc/auto.master, to mount some new directories, and then do something with the files in one of those directories. So I would probably write something like this:
- name: auto.xy is up-to-date
template: src=auto.xy.j2 dest=/etc/auto.xy
notify:- restart autofs
- name: auto.master is up-to-date
lineinfile: dest=/etc/auto.master state=present line=“/xy auto.xy” regexp=^/xy
notify:- restart autofs
- name: symlink to file in /xy is present
file: src=/xy/xy_service dest=/etc/init.d/xy_service state=link
Is there a way I can make sure, that when the symlink is about to be created, the service autofs has definitly been restarted if something has changed? I know I could use “force=yes” to create the symlink anyway, but this doesn’t work if want for instance to execute something in the freshly mounted directory. So how can I achieve this? Is it just a matter of design? Can I group my tasks somehow? I might be really obvious but it seems I can’t figure it out.
And a little follow-up question. Wouldn’t it be nice to execute the notify handlers always when the task was executed that uses this handler?
Thanks,
Bastian