I'd suggest reading up on rolling updates using serial:

https://docs.ansible.com/ansible/latest/playbook_guide/guide_rolling_upgrade.html#the-rolling-upgrade
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_strategies.html#setting-the-batch-size-with-serial

You can use wait_for or wait_for_connection to ensure service availability
before continuing:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_connection_module.html





On Tue, 31 Oct 2023 at 14:08, Sameer Modak <sameer.modak1...@gmail.com>
wrote:

> restart service, check if service is ready to accept connection because it
> takes time to come up. Once we sure its listening on port then only move to
> next host. unless dont move because we can only afford to have one service
> down at a time.
>
> is there any to short hand or ansible native way to handle this using
> ansible module.
>
>
> code:
>
> name: Restart zookeeper followers
>
>   throttle: 1
>
>   any_errors_fatal: true
>
>   shell: |
>
>      systemctl restart {{zookeeper_service_name}}
>
>      timeout 22 sh -c 'until nc localhost {{zookeeper_server_port}}; do
> sleep 1; done'
>
>   when: not zkmode.stdout_lines is search('leader')
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/67ca5f13-855d-4d40-a47a-c0fbe11ea3b5n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/67ca5f13-855d-4d40-a47a-c0fbe11ea3b5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKtKohQPh5bcHs8XNMkxYCk6q8J5xLxV8fejjy%2BU-hZ5mGCfoQ%40mail.gmail.com.

Reply via email to