Notify handler only one in the same role

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.

I think you are going to need to show an example of the playbook/role and the output of this happening.

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.

Note: these tasks are in the same role.