ansible.builtin.postgresql_ping (v2.9.24) — module

Check remote PostgreSQL server availability

| "added in version" 2.8 of ansible.builtin"

Authors: Andrew Klychkov (@Andersson007)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

Simple module to check remote PostgreSQL server availability.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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: PostgreSQL ping dbsrv server using not default credentials and ssl
  postgresql_ping:
    db: protected_db
    login_host: dbsrv
    login_user: secret
    login_password: secret_pass
    ca_cert: /root/root.crt
    ssl_mode: verify-full

Inputs

    
db:
    aliases:
    - login_db
    description:
    - Name of a database to connect to.
    type: str

port:
    aliases:
    - login_port
    default: 5432
    description:
    - Database port to connect to.
    type: int

ca_cert:
    aliases:
    - ssl_rootcert
    description:
    - 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.
    type: str

ssl_mode:
    choices:
    - allow
    - disable
    - prefer
    - require
    - verify-ca
    - verify-full
    default: prefer
    description:
    - 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.
    type: str

login_host:
    default: ''
    description:
    - Host running the database.
    - If you have connection issues when using C(localhost), try to use C(127.0.0.1) instead.
    type: str

login_user:
    default: postgres
    description:
    - The username this module should use to establish its PostgreSQL session.
    type: str

login_password:
    default: ''
    description:
    - The password this module should use to establish its PostgreSQL session.
    type: str

login_unix_socket:
    default: ''
    description:
    - Path to a Unix domain socket for local connections.
    type: str

Outputs

is_available:
  description: PostgreSQL server availability.
  returned: always
  sample: true
  type: bool
server_version:
  description: PostgreSQL server version.
  returned: always
  sample:
    major: 10
    minor: 1
  type: dict

See also