The problem I encountered is quite common, but other solutions did not help me. As follows from this question, when I start my play, only the first notification handler is executed. that is, only firewalld is restarted, but the updated bash profile is not used.
Some people suggested notifying the chain, but I would not want to combine the two tasks with completely different goals. For example, one task might be to add ports to firewalld and then restart; another can update my bash profile to display the date with the output of the command history.
NB the above snippet is not my full .yml, only part of it, so this may or may not work. But the source file works.
tasks
- name: add port-80 to firewalld
firewalld: zone=drop port=80/tcp permanent=true state=enabled
- name: add port-443 to firewalld
firewalld: zone=drop port=443/tcp permanent=true state=enabled
- shell: firewall-cmd
notify:
- Restart firewalld
- name: Enabling time display in history
blockinfile:
dest: ~/.bash_profile
block: |
export HISTTIMEFORMAT="%d/%m/%y %T "
notify:
- Source the updated Bash profile
handlers:
- name: Restart firewalld
service: name=firewalld state=restarted
- name: Source the updated Bash profile
shell: source ~/.bash_profile
...