Notify handler only one in the same role

33 views
Skip to first unread message

Steven Truong

unread,
May 28, 2015, 7:38:59 PM5/28/15
to ansible...@googlegroups.com
Hi all,

I am using ansible 1.9.1 and in the same role I have a couple of notify to the  same service to be restarted.

Apparently, ansible tries to restart 3-4 times for each notify and that is undesirable.  

I could do without notify and create register for each task and then at the end I can have another task that would do when: any of the register variable changed and restart but that is a hack.

Please let me know if there is the right way to do this.

Thank you very much in advance.

Matt Martz

unread,
May 28, 2015, 8:10:03 PM5/28/15
to ansible...@googlegroups.com
I think you are going to need to show an example of the playbook/role and the output of this happening.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cbf63ea0-0594-4aa4-8d6c-ac984e2efe99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Steven Truong

unread,
May 28, 2015, 9:05:35 PM5/28/15
to ansible...@googlegroups.com
Hi Matt,

Here are some tasks that call the same notify and it happened that these files might got changed during the same run.

- name: creates hadoop .sh config files
  template: src={{ item }}.j2 dest=/etc/hadoop/conf.{{ nameservice_id }}/{{ item }} owner=hdfs group=hadoop mode=0755
  with_items:
  - hadoop-env.sh
  - yarn-env.sh
  tags:
  - cdh5_datanode
  - cdh5_datanode_conf
  - cdh5_datanode_conf_sh
  - cdh5_mrv1_slave
  notify: reload datanode

- name: create /etc/default/hadoop-hdfs-datanode
  template: src=hadoop-hdfs-datanode.j2 dest=/etc/default/hadoop-hdfs-datanode owner=root group=root mode=0644
  tags:
  - cdh5_datanode
  - cdh5_datanode_conf
  - cdh5_mrv1_slave
  notify: reload datanode

Currently, I already finished my setup and I just do not have the outputs around but please trust me on this one or you can simply experiment with something similar to this situation.

Thank you very much,
Steven.

On Thursday, May 28, 2015 at 5:10:03 PM UTC-7, Matt Martz wrote:
I think you are going to need to show an example of the playbook/role and the output of this happening.

On Thursday, May 28, 2015, Steven Truong <djatl...@gmail.com> wrote:
Hi all,

I am using ansible 1.9.1 and in the same role I have a couple of notify to the  same service to be restarted.

Apparently, ansible tries to restart 3-4 times for each notify and that is undesirable.  

I could do without notify and create register for each task and then at the end I can have another task that would do when: any of the register variable changed and restart but that is a hack.

Please let me know if there is the right way to do this.

Thank you very much in advance.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Steven Truong

unread,
May 28, 2015, 9:06:41 PM5/28/15
to ansible...@googlegroups.com
Note: these tasks are in the same role.
Reply all
Reply to author
Forward
0 new messages