postgresql_ping
Check remote PostgreSQL server availability
Collection: community.postgresql
Full Name: community.postgresql.postgresql_ping
Synopsis
Check remote PostgreSQL server availability
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| login_user | str | The username this module should use to establish its PostgreSQL session. | ||
| login_password | str | The password this module should use to establish its PostgreSQL session. | ||
| login_host | str | Host running the database. If you have connection issues when using C(localhost), try to use C(127.0.0.1) instead. | ||
| login_unix_socket | str | Path to a Unix domain socket for local connections. | ||
| login_port | int | Database 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_mode | str | prefer | Determines 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_cert | str | Specifies 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_cert | path | Specifies the file name of the client SSL certificate. | ||
| ssl_key | path | Specifies the location for the secret key used for the client certificate. | ||
| connect_params | dict | Any additional parameters to be passed to libpg. These parameters take precedence. | ||
| login_db | str | Name of a database to connect to. The V(db) alias is deprecated and will be removed in version 5.0.0. | ||
| session_role | str | Switch 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_input | bool | true | If 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