is there any order by clause for hosts to execute task in certain order

Hello Team,

We have a situation where we have to run same script on all 3 machines but in specific order like first it should be run on follower and then on leader.

now to achieve this i have to repeat same task again with different condition. Can it be achieve in one ???

  • name: Kill running java processes and start newly configured systemd

throttle: 1

ignore_errors: yes

any_errors_fatal: true

shell: ‘/bin/bash /tmp/zkcheck.sh’

register: zkstart

failed_when: zkstart.rc != 0

when: not zkmode.stdout_lines is search(‘leader’)

  • name: As all followers are up now repeat kill running java cp and start for leader

any_errors_fatal: true

shell: ‘/bin/bash /tmp/zkcheck.sh’

register: zkstart

failed_when: zkstart.rc != 0

when: zkmode.stdout_lines is search(‘leader’)

Hi,

This should help

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_strategies.html#ordering-execution-based-on-inventory

Regards