PARALLAX

postgresql_ping

Check remote PostgreSQL server availability

Collection: community.postgresql

Full Name: community.postgresql.postgresql_ping

Synopsis

Check remote PostgreSQL server availability

Parameters

NameTypeRequiredDefaultDescription
login_userstrThe username this module should use to establish its PostgreSQL session.
login_passwordstrThe password this module should use to establish its PostgreSQL session.
login_hoststrHost running the database. If you have connection issues when using C(localhost), try to use C(127.0.0.1) instead.
login_unix_socketstrPath to a Unix domain socket for local connections.
login_portintDatabase port to connect to. The C(port) alias is deprecated and will be removed in the next major release. Use C(login_port) instead.
ssl_modestrpreferDetermines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. See U(https://www.postgresql.org/docs/current/static/libpq-ssl.html) for more information on the modes. Default of C(prefer) matches libpq default.
ca_certstrSpecifies the name of a file containing SSL certificate authority (CA) certificate(s). If the file exists, the server’s certificate will be verified to be signed by one of these authorities.
ssl_certpathSpecifies the file name of the client SSL certificate.
ssl_keypathSpecifies the location for the secret key used for the client certificate.
connect_paramsdictAny additional parameters to be passed to libpg. These parameters take precedence.
login_dbstrName of a database to connect to. The V(db) alias is deprecated and will be removed in version 5.0.0.
session_rolestrSwitch to session_role after connecting. The specified session_role must be a role that the current login_user is a member of. Permissions checking for SQL commands is carried out as though the session_role were the one that had logged in originally.
trust_inputbooltrueIf C(false), check whether a value of I(session_role) is potentially dangerous. It makes sense to use C(false) only when SQL injections via I(session_role) are possible.

Example

yaml
# PostgreSQL ping dbsrv server from the shell:
# ansible dbsrv -m postgresql_ping

# In the example below you need to generate certificates previously.
# See https://www.postgresql.org/docs/current/libpq-ssl.html for more information.
- name: >
    Ping PostgreSQL server using non-default credentials and SSL
    registering the return values into the result variable for future use
  community.postgresql.postgresql_ping:
    login_db: protected_db
    login_host: dbsrv
    login_user: secret
    login_password: secret_pass
    ca_cert: /root/root.crt
    ssl_mode: verify-full
  register: result
  # If you need to fail when the server is not available,
  # uncomment the following line:
  # failed_when: not result.is_available
Search
    ↑ ↓ move↵ openesc close