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

Add or remove PostgreSQL extensions from a database

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

Authors: Daniel Schep (@dschep), Thomas O'Donnell (@andytom), Sandro Santilli (@strk), Andrew Klychkov (@Andersson007)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

Add or remove PostgreSQL extensions from a database.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Adds postgis extension to the database acme in the schema foo
  postgresql_ext:
    name: postgis
    db: acme
    schema: foo
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Removes postgis extension to the database acme
  postgresql_ext:
    name: postgis
    db: acme
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Adds earthdistance extension to the database template1 cascade
  postgresql_ext:
    name: earthdistance
    db: template1
    cascade: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# In the example below, if earthdistance extension is installed,
# it will be removed too because it depends on cube:
- name: Removes cube extension from the database acme cascade
  postgresql_ext:
    name: cube
    db: acme
    cascade: yes
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create extension foo of version 1.2 or update it if it's already created
  postgresql_ext:
    db: acme
    name: foo
    version: 1.2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Assuming extension foo is created, update it to the latest version
  postgresql_ext:
    db: acme
    name: foo
    version: latest

Inputs

    
db:
    aliases:
    - login_db
    description:
    - Name of the database to add or remove the extension to/from.
    required: true
    type: str

name:
    aliases:
    - ext
    description:
    - Name of the extension 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 database extension state.
    type: str

schema:
    description:
    - Name of the schema to add the extension to.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

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
    version_added: '2.8'
    version_added_collection: ansible.builtin

cascade:
    default: false
    description:
    - Automatically install/remove any extensions that this extension depends on that
      are not already installed/removed (supported since PostgreSQL 9.6).
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

version:
    description:
    - Extension version to add or update to. Has effect with I(state=present) only.
    - If not specified, the latest extension version will be created.
    - It can't downgrade an extension version. When version downgrade is needed, remove
      the extension and create new one with appropriate version.
    - Set I(version=latest) to update the extension to the latest available version.
    type: str
    version_added: '2.9'
    version_added_collection: ansible.builtin

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 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
    version_added: '2.8'
    version_added_collection: ansible.builtin

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

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
    version_added: '2.8'
    version_added_collection: ansible.builtin

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
    version_added: '2.8'
    version_added_collection: ansible.builtin

Outputs

query:
  description: List of executed queries.
  returned: always
  sample:
  - DROP EXTENSION "acme"
  type: list

See also