postgresql_slot – Add or remove slots from a PostgreSQL database
postgresql_slot – Add or remove slots from a PostgreSQL database
New in version 2.8.
Synopsis
- Add or remove physical or logical slots from a PostgreSQL database.
Requirements
The below requirements are needed on the host that executes this module.
- psycopg2
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
ca_cert string |
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.
| |
db string |
Name of database to connect to.
| |
immediately_reserve boolean |
|
Optional parameter the when Is available from PostgreSQL version 9.6. Uses only with slot_type=physical. Mutually exclusive with slot_type=logical. |
login_host string |
Host running the database. | |
login_password string |
The password used to authenticate with. | |
login_unix_socket string |
Path to a Unix domain socket for local connections. | |
login_user string |
Default: "postgres" |
The username used to authenticate with. |
name string / required |
Name of the slot to add or remove.
| |
output_plugin string |
Default: "test_decoding" |
All logical slots must indicate which output plugin decoder they're using. This parameter does not apply to physical slots. It will be ignored with slot_type=physical. |
port integer |
Default: 5432 |
Database port to connect to.
|
session_role string |
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. | |
slot_type string |
|
Slot type. |
ssl_mode string |
|
Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. See https://www.postgresql.org/docs/current/static/libpq-ssl.html for more information on the modes. Default of |
state string |
|
The slot state. state=present implies the slot must be present in the system. state=absent implies the groups must be revoked from target_roles. |
Notes
Note
- Physical replication slots were introduced to PostgreSQL with version 9.4, while logical replication slots were added beginning with version 10.0.
- The default authentication assumes that you are either logging in as or sudo’ing to the postgres account on the host.
- To avoid “Peer authentication failed for user postgres” error, use postgres user as a become_user.
- This module uses psycopg2, a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module.
- If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host.
- For Ubuntu-based systems, install the postgresql, libpq-dev, and python-psycopg2 packages
- The default authentication assumes that you are either logging in as or sudo’ing to the
postgres
account on the host. - This module uses psycopg2, a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module. If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host. For Ubuntu-based systems, install the
postgresql
,libpq-dev
, andpython-psycopg2
packages on the remote host before using this module. - The ca_cert parameter requires at least Postgres version 8.4 and psycopg2 version 2.4.3.
Examples
- name: Create physical_one physical slot if doesn't exist
become_user: postgres
postgresql_slot:
slot_name: physical_one
db: ansible
- name: Remove physical_one slot if exists
become_user: postgres
postgresql_slot:
slot_name: physical_one
db: ansible
state: absent
- name: Create logical_one logical slot to the database acme if doen't exist
postgresql_slot:
name: logical_slot_one
slot_type: logical
state: present
output_plugin: custom_decoder_one
- name: Remove logical_one slot if exists from the cluster running on another host and non-standard port
postgresql_slot:
name: logical_one
login_host: mydatabase.example.org
port: 5433
login_user: ourSuperuser
login_password: thePassword
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
name string |
always |
Name of the slot
Sample: physical_one |
queries string |
always |
List of executed queries.
Sample: ["SELECT pg_create_physical_replication_slot('physical_one', False, False)"] |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- John Scalia (@jscalia)
- Andew Klychkov (@Andersson007)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/postgresql_slot_module.html