I'm writing a bunch of tasks and playbooks to bring up new VM nodes:
1) installing postfix
2) modifying /etc/postfix/main.cf to configuring it as a satellite
a) register a handler to restart postfix
3) install apt-listchanges
4) apt-get update
5) apt-get -y dist-upgrade
However, it's only after 5 does the postfix handler fire, so the email that apt-listchanges sends goes to /var/mail/root instead of me. So I'm now using:
- name: write /etc/aliases to forward all email to me.
action: lineinfile dest=/etc/aliases regexp="^root:.*" line=root:blair@orcaware.com backup=yes
register: last_result
Is there an idiom for notify that we can use an immediate notify to fire the handler then instead of writing register and only_if? Is there an 'immediate_notify'?
I just tried using this with the most current devel branch and it didn’t work as expected. I had to manually register last_result for it to work, but also there is an inherent issue in this. If the task you want the last result from is skipped (in the case of using command and the creates attribute), you do not get a last_result variable set. Perhaps instead of having the command module skip the task it should register it with “ok”?
A work around that worked for me is to declare the variable with a value of zero, so when the task is skipped, it behaves as if the tasks had not run or failed. Look at this thread: