postgresql_ext – Add or remove PostgreSQL extensions from a database¶
Parameters¶
Notes¶
Note
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 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 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.
See Also¶
See also
- PostgreSQL extensions
General information about PostgreSQL extensions.
- CREATE EXTENSION reference
Complete reference of the CREATE EXTENSION command documentation.
- ALTER EXTENSION reference
Complete reference of the ALTER EXTENSION command documentation.
- DROP EXTENSION reference
Complete reference of the DROP EXTENSION command documentation.
Examples¶
- name: Adds postgis extension to the database acme in the schema foo
postgresql_ext:
name: postgis
db: acme
schema: foo
- name: Removes postgis extension to the database acme
postgresql_ext:
name: postgis
db: acme
state: absent
- name: Adds earthdistance extension to the database template1 cascade
postgresql_ext:
name: earthdistance
db: template1
cascade: true
# 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
- 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
- name: Assuming extension foo is created, update it to the latest version
postgresql_ext:
db: acme
name: foo
version: latest
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
query
list
|
always |
List of executed queries.
Sample:
['DROP EXTENSION "acme"']
|
Status¶
This module is not guaranteed to have a backwards compatible interface. [preview]
This module is maintained by the Ansible Community. [community]
Authors¶
Daniel Schep (@dschep)
Thomas O’Donnell (@andytom)
Sandro Santilli (@strk)
Andrew Klychkov (@Andersson007)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.