You can make use of ansible handlers for notifying a single task several times. Once you declare a handler in ansible, it will be executed only when it gets notified by another task. Also, every handler in getting executed at the end of the playbook run irrespective of the notifications by tasks.
To achieve this, you need to create a handlers folder in your role and a main.yml file inside handlers folder. Declare your handlers in the main.yml file as shown below.
- name: restart httpd
- service: state=restarted
And in your task, you can notify the handler using the following syntax.
- name: template configuration for httpd.conf
template: <span class="nv">src</span><span class="o">=</span>template.j2 <span class="nv">dest</span><span class="o">=</span>/etc/httpd.conf
notify: - restart httpd