community.general.postgresql_slot (1.3.14) — module

Add or remove replication slots from a PostgreSQL database

Authors: John Scalia (@jscalia), Andrew Klychkov (@Andersson007), Thomas O'Donnell (@andytom)

Install collection

Install with ansible-galaxy collection install community.general:==1.3.14


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.14

Description

Add or remove physical or logical replication slots from a PostgreSQL database.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create physical_one physical slot if doesn't exist
  become_user: postgres
  community.general.postgresql_slot:
    slot_name: physical_one
    db: ansible
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove physical_one slot if exists
  become_user: postgres
  community.general.postgresql_slot:
    slot_name: physical_one
    db: ansible
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create logical_one logical slot to the database acme if doesn't exist
  community.general.postgresql_slot:
    name: logical_slot_one
    slot_type: logical
    state: present
    output_plugin: custom_decoder_one
    db: "acme"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove logical_one slot if exists from the cluster running on another host and non-standard port
  community.general.postgresql_slot:
    name: logical_one
    login_host: mydatabase.example.org
    port: 5433
    login_user: ourSuperuser
    login_password: thePassword
    state: absent

Inputs

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

name:
    aliases:
    - slot_name
    description:
    - Name of the replication slot to add or remove.
    required: true
    type: str

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

state:
    choices:
    - absent
    - present
    default: present
    description:
    - The slot state.
    - I(state=present) implies the slot must be present in the system.
    - I(state=absent) implies the I(groups) must be revoked from I(target_roles).
    type: str

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

slot_type:
    choices:
    - logical
    - physical
    default: physical
    description:
    - Slot type.
    type: str

login_host:
    description:
    - Host running the database.
    type: str

login_user:
    default: postgres
    description:
    - The username used to authenticate with.
    type: str

trust_input:
    default: true
    description:
    - If C(no), check the value of I(session_role) is potentially dangerous.
    - It makes sense to use C(no) only when SQL injections via I(session_role) are possible.
    type: bool
    version_added: 0.2.0
    version_added_collection: community.general

session_role:
    description:
    - 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.
    type: str

output_plugin:
    default: test_decoding
    description:
    - 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 I(slot_type=physical).
    type: str

login_password:
    description:
    - The password used to authenticate with.
    type: str

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

immediately_reserve:
    default: false
    description:
    - Optional parameter that when C(yes) specifies that the LSN for this replication
      slot be reserved immediately, otherwise the default, C(no), specifies that the LSN
      is reserved on the first connection from a streaming replication client.
    - Is available from PostgreSQL version 9.6.
    - Uses only with I(slot_type=physical).
    - Mutually exclusive with I(slot_type=logical).
    type: bool

Outputs

name:
  description: Name of the slot
  returned: always
  sample: physical_one
  type: str
queries:
  description: List of executed queries.
  returned: always
  sample:
  - SELECT pg_create_physical_replication_slot('physical_one', False, False)
  type: str

See also