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

21 views
Skip to first unread message

Sameer Modak

unread,
Jul 12, 2023, 10:54:10 AM7/12/23
to Ansible Project


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')

Stephen Maher

unread,
Jul 12, 2023, 11:42:46 AM7/12/23
to 'Rowe, Walter P. (Fed)' via Ansible Project
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/80a84c53-2700-4807-afa9-45458969e395n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages