On Sun, 4 Jun 2023 12:06:39 +0200 (CEST)
dulhaver via Ansible Project <[email protected]> wrote:

> ... couple of postgres-remotes ...
> ... to check whether postgres1 has a connection via port 5432 to a specific 
> IP address ...
> ... what would be the right approach (aka module) for such in an Ansible TASK?

Use the module *wait_for*. See
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html


If you run the play on *postgres1* the task is simple

  - hosts: postgres1
    tasks:
      - wait_for:
          host: <specific IP address>
          port: 5432

If you run the play on multiple hosts you might want to run
once and delegate the task 

  - hosts: all
    tasks:
      - wait_for:
          host: <specific IP address>
          port: 5432
        delegate_to: postgres1
        run_once: true

See: pg_isready
https://www.postgresql.org/docs/current/app-pg-isready.html

-- 
Vladimir Botka

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20230604133822.77edfdfe%40gmail.com.

Attachment: pgpb_WiJgBzw3.pgp
Description: OpenPGP digital signature

Reply via email to