Execution order of handles in notify

19 views
Skip to first unread message

Igor Cicimov

unread,
Jul 13, 2016, 4:25:22 AM7/13/16
to Ansible Project
Hi,

I can't find anywhere in the documentation any mention of the task order executed under notify. Having the example from the web docs:
 
- name: template configuration file
  template: src=template.j2 dest=/etc/foo.conf
  notify:
     - restart memcached
     - restart apache

does this guarantee that memcached is always going to be restarted before apache when the handles get flushed?

Thanks,
Igor

Kai Stian Olstad

unread,
Jul 13, 2016, 5:21:08 AM7/13/16
to ansible...@googlegroups.com
On 13.07.2016 10:25, Igor Cicimov wrote:
> - name: template configuration file
> template: src=template.j2 dest=/etc/foo.conf
> notify:
> - restart memcached
> - restart apache
>
>
> does this guarantee that memcached is always going to be restarted
> before
> apache when the handles get flushed?

No.
All notify will run at the end an in the order they are in handlers
file.

--
Kai Stian Olstad

Igor Cicimov

unread,
Jul 13, 2016, 6:29:07 AM7/13/16
to Ansible Project, ansible-pr...@olstad.com

I guess same goes in case of different tasks calling different handles? Like:

- task1
  notify:
     - restart memcached

- tasks2 notify: - restart apache

Kai Stian Olstad

unread,
Jul 13, 2016, 6:55:01 AM7/13/16
to ansible...@googlegroups.com
On 13.07.2016 12:29, Igor Cicimov wrote:
> On Wednesday, July 13, 2016 at 7:21:08 PM UTC+10, Kai Stian Olstad
> wrote:
>> No.
>> All notify will run at the end an in the order they are in handlers
>> file.
>>
>
> I guess same goes in case of different tasks calling different handles?
> Like:
>
> - task1
> notify:
> - restart memcached
>
> - tasks2
> notify:
> - restart apache

Yes.
The order the handlers are being notify has no influence on the order
they are executed.
They will always be executed in the order they are in the handlers file.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages