1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

postgresql modules: fix examples to use FQCN (#643)

This commit is contained in:
Andrew Klychkov 2020-07-13 12:54:34 +03:00 committed by GitHub
parent a424ee71e3
commit f62b8027e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 138 additions and 138 deletions

View file

@ -100,12 +100,12 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Copy text TAB-separated data from file /tmp/data.txt to acme table - name: Copy text TAB-separated data from file /tmp/data.txt to acme table
postgresql_copy: community.general.postgresql_copy:
copy_from: /tmp/data.txt copy_from: /tmp/data.txt
dst: acme dst: acme
- name: Copy CSV (comma-separated) data from file /tmp/data.csv to columns id, name of table acme - name: Copy CSV (comma-separated) data from file /tmp/data.csv to columns id, name of table acme
postgresql_copy: community.general.postgresql_copy:
copy_from: /tmp/data.csv copy_from: /tmp/data.csv
dst: acme dst: acme
columns: id,name columns: id,name
@ -115,7 +115,7 @@ EXAMPLES = r'''
- name: > - name: >
Copy text vertical-bar-separated data from file /tmp/data.txt to bar table. Copy text vertical-bar-separated data from file /tmp/data.txt to bar table.
The NULL values are specified as N The NULL values are specified as N
postgresql_copy: community.general.postgresql_copy:
copy_from: /tmp/data.csv copy_from: /tmp/data.csv
dst: bar dst: bar
options: options:
@ -123,19 +123,19 @@ EXAMPLES = r'''
null: 'N' null: 'N'
- name: Copy data from acme table to file /tmp/data.txt in text format, TAB-separated - name: Copy data from acme table to file /tmp/data.txt in text format, TAB-separated
postgresql_copy: community.general.postgresql_copy:
src: acme src: acme
copy_to: /tmp/data.txt copy_to: /tmp/data.txt
- name: Copy data from SELECT query to/tmp/data.csv in CSV format - name: Copy data from SELECT query to/tmp/data.csv in CSV format
postgresql_copy: community.general.postgresql_copy:
src: 'SELECT * FROM acme' src: 'SELECT * FROM acme'
copy_to: /tmp/data.csv copy_to: /tmp/data.csv
options: options:
format: csv format: csv
- name: Copy CSV data from my_table to gzip - name: Copy CSV data from my_table to gzip
postgresql_copy: community.general.postgresql_copy:
src: my_table src: my_table
copy_to: 'gzip > /tmp/data.csv.gz' copy_to: 'gzip > /tmp/data.csv.gz'
program: yes program: yes
@ -145,7 +145,7 @@ EXAMPLES = r'''
- name: > - name: >
Copy data from columns id, name of table bar to /tmp/data.txt. Copy data from columns id, name of table bar to /tmp/data.txt.
Output format is text, vertical-bar-separated, NULL as N Output format is text, vertical-bar-separated, NULL as N
postgresql_copy: community.general.postgresql_copy:
src: bar src: bar
columns: columns:
- id - id

View file

@ -137,12 +137,12 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create a new database with name "acme" - name: Create a new database with name "acme"
postgresql_db: community.general.postgresql_db:
name: acme name: acme
# Note: If a template different from "template0" is specified, encoding and locale settings must match those of the template. # Note: If a template different from "template0" is specified, encoding and locale settings must match those of the template.
- name: Create a new database with name "acme" and specific encoding and locale # settings. - name: Create a new database with name "acme" and specific encoding and locale # settings.
postgresql_db: community.general.postgresql_db:
name: acme name: acme
encoding: UTF-8 encoding: UTF-8
lc_collate: de_DE.UTF-8 lc_collate: de_DE.UTF-8
@ -151,38 +151,38 @@ EXAMPLES = r'''
# Note: Default limit for the number of concurrent connections to a specific database is "-1", which means "unlimited" # Note: Default limit for the number of concurrent connections to a specific database is "-1", which means "unlimited"
- name: Create a new database with name "acme" which has a limit of 100 concurrent connections - name: Create a new database with name "acme" which has a limit of 100 concurrent connections
postgresql_db: community.general.postgresql_db:
name: acme name: acme
conn_limit: "100" conn_limit: "100"
- name: Dump an existing database to a file - name: Dump an existing database to a file
postgresql_db: community.general.postgresql_db:
name: acme name: acme
state: dump state: dump
target: /tmp/acme.sql target: /tmp/acme.sql
- name: Dump an existing database to a file excluding the test table - name: Dump an existing database to a file excluding the test table
postgresql_db: community.general.postgresql_db:
name: acme name: acme
state: dump state: dump
target: /tmp/acme.sql target: /tmp/acme.sql
dump_extra_args: --exclude-table=test dump_extra_args: --exclude-table=test
- name: Dump an existing database to a file (with compression) - name: Dump an existing database to a file (with compression)
postgresql_db: community.general.postgresql_db:
name: acme name: acme
state: dump state: dump
target: /tmp/acme.sql.gz target: /tmp/acme.sql.gz
- name: Dump a single schema for an existing database - name: Dump a single schema for an existing database
postgresql_db: community.general.postgresql_db:
name: acme name: acme
state: dump state: dump
target: /tmp/acme.sql target: /tmp/acme.sql
target_opts: "-n public" target_opts: "-n public"
- name: Dump only table1 and table2 from the acme database - name: Dump only table1 and table2 from the acme database
postgresql_db: community.general.postgresql_db:
name: acme name: acme
state: dump state: dump
target: /tmp/table1_table2.sql target: /tmp/table1_table2.sql
@ -192,7 +192,7 @@ EXAMPLES = r'''
# the tablespace will be changed to foo. Access to the database will be locked # the tablespace will be changed to foo. Access to the database will be locked
# until the copying of database files is finished. # until the copying of database files is finished.
- name: Create a new database called foo in tablespace bar - name: Create a new database called foo in tablespace bar
postgresql_db: community.general.postgresql_db:
name: foo name: foo
tablespace: bar tablespace: bar
''' '''

View file

@ -119,19 +119,19 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Adds postgis extension to the database acme in the schema foo - name: Adds postgis extension to the database acme in the schema foo
postgresql_ext: community.general.postgresql_ext:
name: postgis name: postgis
db: acme db: acme
schema: foo schema: foo
- name: Removes postgis extension to the database acme - name: Removes postgis extension to the database acme
postgresql_ext: community.general.postgresql_ext:
name: postgis name: postgis
db: acme db: acme
state: absent state: absent
- name: Adds earthdistance extension to the database template1 cascade - name: Adds earthdistance extension to the database template1 cascade
postgresql_ext: community.general.postgresql_ext:
name: earthdistance name: earthdistance
db: template1 db: template1
cascade: true cascade: true
@ -139,20 +139,20 @@ EXAMPLES = r'''
# In the example below, if earthdistance extension is installed, # In the example below, if earthdistance extension is installed,
# it will be removed too because it depends on cube: # it will be removed too because it depends on cube:
- name: Removes cube extension from the database acme cascade - name: Removes cube extension from the database acme cascade
postgresql_ext: community.general.postgresql_ext:
name: cube name: cube
db: acme db: acme
cascade: yes cascade: yes
state: absent state: absent
- name: Create extension foo of version 1.2 or update it if it's already created - name: Create extension foo of version 1.2 or update it if it's already created
postgresql_ext: community.general.postgresql_ext:
db: acme db: acme
name: foo name: foo
version: 1.2 version: 1.2
- name: Assuming extension foo is created, update it to the latest version - name: Assuming extension foo is created, update it to the latest version
postgresql_ext: community.general.postgresql_ext:
db: acme db: acme
name: foo name: foo
version: latest version: latest

View file

@ -150,14 +150,14 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create btree index if not exists test_idx concurrently covering columns id and name of table products - name: Create btree index if not exists test_idx concurrently covering columns id and name of table products
postgresql_idx: community.general.postgresql_idx:
db: acme db: acme
table: products table: products
columns: id,name columns: id,name
name: test_idx name: test_idx
- name: Create btree index test_idx concurrently with tablespace called ssd and storage parameter - name: Create btree index test_idx concurrently with tablespace called ssd and storage parameter
postgresql_idx: community.general.postgresql_idx:
db: acme db: acme
table: products table: products
columns: columns:
@ -169,7 +169,7 @@ EXAMPLES = r'''
- fillfactor=90 - fillfactor=90
- name: Create gist index test_gist_idx concurrently on column geo_data of table map - name: Create gist index test_gist_idx concurrently on column geo_data of table map
postgresql_idx: community.general.postgresql_idx:
db: somedb db: somedb
table: map table: map
idxtype: gist idxtype: gist
@ -178,7 +178,7 @@ EXAMPLES = r'''
# Note: for the example below pg_trgm extension must be installed for gin_trgm_ops # Note: for the example below pg_trgm extension must be installed for gin_trgm_ops
- name: Create gin index gin0_idx not concurrently on column comment of table test - name: Create gin index gin0_idx not concurrently on column comment of table test
postgresql_idx: community.general.postgresql_idx:
idxname: gin0_idx idxname: gin0_idx
table: test table: test
columns: comment gin_trgm_ops columns: comment gin_trgm_ops
@ -186,13 +186,13 @@ EXAMPLES = r'''
idxtype: gin idxtype: gin
- name: Drop btree test_idx concurrently - name: Drop btree test_idx concurrently
postgresql_idx: community.general.postgresql_idx:
db: mydb db: mydb
idxname: test_idx idxname: test_idx
state: absent state: absent
- name: Drop test_idx cascade - name: Drop test_idx cascade
postgresql_idx: community.general.postgresql_idx:
db: mydb db: mydb
idxname: test_idx idxname: test_idx
state: absent state: absent
@ -200,7 +200,7 @@ EXAMPLES = r'''
concurrent: no concurrent: no
- name: Create btree index test_idx concurrently on columns id,comment where column id > 1 - name: Create btree index test_idx concurrently on columns id,comment where column id > 1
postgresql_idx: community.general.postgresql_idx:
db: mydb db: mydb
table: test table: test
columns: id,comment columns: id,comment
@ -208,7 +208,7 @@ EXAMPLES = r'''
cond: id > 1 cond: id > 1
- name: Create unique btree index if not exists test_unique_idx on column name of table products - name: Create unique btree index if not exists test_unique_idx on column name of table products
postgresql_idx: community.general.postgresql_idx:
db: acme db: acme
table: products table: products
columns: name columns: name

View file

@ -72,13 +72,13 @@ EXAMPLES = r'''
- name: Collect PostgreSQL version and extensions - name: Collect PostgreSQL version and extensions
become: yes become: yes
become_user: postgres become_user: postgres
postgresql_info: community.general.postgresql_info:
filter: ver*,ext* filter: ver*,ext*
- name: Collect all info except settings and roles - name: Collect all info except settings and roles
become: yes become: yes
become_user: postgres become_user: postgres
postgresql_info: community.general.postgresql_info:
filter: "!settings,!roles" filter: "!settings,!roles"
# On FreeBSD with PostgreSQL 9.5 version and lower use pgsql user to become # On FreeBSD with PostgreSQL 9.5 version and lower use pgsql user to become
@ -86,7 +86,7 @@ EXAMPLES = r'''
- name: Collect tablespaces and repl_slots info - name: Collect tablespaces and repl_slots info
become: yes become: yes
become_user: pgsql become_user: pgsql
postgresql_info: community.general.postgresql_info:
db: postgres db: postgres
filter: filter:
- tablesp* - tablesp*
@ -95,7 +95,7 @@ EXAMPLES = r'''
- name: Collect all info except databases - name: Collect all info except databases
become: yes become: yes
become_user: postgres become_user: postgres
postgresql_info: community.general.postgresql_info:
filter: filter:
- "!databases" - "!databases"
''' '''

View file

@ -133,13 +133,13 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Add language pltclu to database testdb if it doesn't exist - name: Add language pltclu to database testdb if it doesn't exist
postgresql_lang: db=testdb lang=pltclu state=present community.general.postgresql_lang: db=testdb lang=pltclu state=present
# Add language pltclu to database testdb if it doesn't exist and mark it as trusted. # Add language pltclu to database testdb if it doesn't exist and mark it as trusted.
# Marks the language as trusted if it exists but isn't trusted yet. # Marks the language as trusted if it exists but isn't trusted yet.
# force_trust makes sure that the language will be marked as trusted # force_trust makes sure that the language will be marked as trusted
- name: Add language pltclu to database testdb if it doesn't exist and mark it as trusted - name: Add language pltclu to database testdb if it doesn't exist and mark it as trusted
postgresql_lang: community.general.postgresql_lang:
db: testdb db: testdb
lang: pltclu lang: pltclu
state: present state: present
@ -147,27 +147,27 @@ EXAMPLES = r'''
force_trust: yes force_trust: yes
- name: Remove language pltclu from database testdb - name: Remove language pltclu from database testdb
postgresql_lang: community.general.postgresql_lang:
db: testdb db: testdb
lang: pltclu lang: pltclu
state: absent state: absent
- name: Remove language pltclu from database testdb and remove all dependencies - name: Remove language pltclu from database testdb and remove all dependencies
postgresql_lang: community.general.postgresql_lang:
db: testdb db: testdb
lang: pltclu lang: pltclu
state: absent state: absent
cascade: yes cascade: yes
- name: Remove language c from database testdb but ignore errors if something prevents the removal - name: Remove language c from database testdb but ignore errors if something prevents the removal
postgresql_lang: community.general.postgresql_lang:
db: testdb db: testdb
lang: pltclu lang: pltclu
state: absent state: absent
fail_on_drop: no fail_on_drop: no
- name: In testdb change owner of mylang to alice - name: In testdb change owner of mylang to alice
postgresql_lang: community.general.postgresql_lang:
db: testdb db: testdb
lang: mylang lang: mylang
owner: alice owner: alice

View file

@ -93,7 +93,7 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Grant role read_only to alice and bob - name: Grant role read_only to alice and bob
postgresql_membership: community.general.postgresql_membership:
group: read_only group: read_only
target_roles: target_roles:
- alice - alice
@ -103,7 +103,7 @@ EXAMPLES = r'''
# you can also use target_roles: alice,bob,etc to pass the role list # you can also use target_roles: alice,bob,etc to pass the role list
- name: Revoke role read_only and exec_func from bob. Ignore if roles don't exist - name: Revoke role read_only and exec_func from bob. Ignore if roles don't exist
postgresql_membership: community.general.postgresql_membership:
groups: groups:
- read_only - read_only
- exec_func - exec_func

View file

@ -91,41 +91,41 @@ EXAMPLES = r'''
# ansible -m postgresql_owner -a "db=bar new_owner=alice obj_name=myfunc obj_type=function" # ansible -m postgresql_owner -a "db=bar new_owner=alice obj_name=myfunc obj_type=function"
- name: The same as above by playbook - name: The same as above by playbook
postgresql_owner: community.general.postgresql_owner:
db: bar db: bar
new_owner: alice new_owner: alice
obj_name: myfunc obj_name: myfunc
obj_type: function obj_type: function
- name: Set owner as bob for table acme in database bar - name: Set owner as bob for table acme in database bar
postgresql_owner: community.general.postgresql_owner:
db: bar db: bar
new_owner: bob new_owner: bob
obj_name: acme obj_name: acme
obj_type: table obj_type: table
- name: Set owner as alice for view test_view in database bar - name: Set owner as alice for view test_view in database bar
postgresql_owner: community.general.postgresql_owner:
db: bar db: bar
new_owner: alice new_owner: alice
obj_name: test_view obj_name: test_view
obj_type: view obj_type: view
- name: Set owner as bob for tablespace ssd in database foo - name: Set owner as bob for tablespace ssd in database foo
postgresql_owner: community.general.postgresql_owner:
db: foo db: foo
new_owner: bob new_owner: bob
obj_name: ssd obj_name: ssd
obj_type: tablespace obj_type: tablespace
- name: Reassign all object in database bar owned by bob to alice - name: Reassign all object in database bar owned by bob to alice
postgresql_owner: community.general.postgresql_owner:
db: bar db: bar
new_owner: alice new_owner: alice
reassign_owned_by: bob reassign_owned_by: bob
- name: Reassign all object in database bar owned by bob and bill to alice - name: Reassign all object in database bar owned by bob and bill to alice
postgresql_owner: community.general.postgresql_owner:
db: bar db: bar
new_owner: alice new_owner: alice
reassign_owned_by: reassign_owned_by:

View file

@ -123,7 +123,7 @@ author: Sebastiaan Mannem (@sebasmannem)
EXAMPLES = ''' EXAMPLES = '''
- name: Grant users joe and simon access to databases sales and logistics from ipv6 localhost ::1/128 using peer authentication. - name: Grant users joe and simon access to databases sales and logistics from ipv6 localhost ::1/128 using peer authentication.
postgresql_pg_hba: community.general.postgresql_pg_hba:
dest: /var/lib/postgres/data/pg_hba.conf dest: /var/lib/postgres/data/pg_hba.conf
contype: host contype: host
users: joe,simon users: joe,simon
@ -133,7 +133,7 @@ EXAMPLES = '''
create: true create: true
- name: Grant user replication from network 192.168.0.100/24 access for replication with client cert authentication. - name: Grant user replication from network 192.168.0.100/24 access for replication with client cert authentication.
postgresql_pg_hba: community.general.postgresql_pg_hba:
dest: /var/lib/postgres/data/pg_hba.conf dest: /var/lib/postgres/data/pg_hba.conf
contype: host contype: host
users: replication users: replication
@ -142,7 +142,7 @@ EXAMPLES = '''
method: cert method: cert
- name: Revoke access from local user mary on database mydb. - name: Revoke access from local user mary on database mydb.
postgresql_pg_hba: community.general.postgresql_pg_hba:
dest: /var/lib/postgres/data/pg_hba.conf dest: /var/lib/postgres/data/pg_hba.conf
contype: local contype: local
users: mary users: mary

View file

@ -51,7 +51,7 @@ EXAMPLES = r'''
# In the example below you need to generate certificates previously. # In the example below you need to generate certificates previously.
# See https://www.postgresql.org/docs/current/libpq-ssl.html for more information. # See https://www.postgresql.org/docs/current/libpq-ssl.html for more information.
- name: PostgreSQL ping dbsrv server using not default credentials and ssl - name: PostgreSQL ping dbsrv server using not default credentials and ssl
postgresql_ping: community.general.postgresql_ping:
db: protected_db db: protected_db
login_host: dbsrv login_host: dbsrv
login_user: secret login_user: secret

View file

@ -202,7 +202,7 @@ EXAMPLES = r'''
# GRANT SELECT, INSERT, UPDATE ON TABLE public.books, public.authors # GRANT SELECT, INSERT, UPDATE ON TABLE public.books, public.authors
# TO librarian, reader WITH GRANT OPTION # TO librarian, reader WITH GRANT OPTION
- name: Grant privs to librarian and reader on database library - name: Grant privs to librarian and reader on database library
postgresql_privs: community.general.postgresql_privs:
database: library database: library
state: present state: present
privs: SELECT,INSERT,UPDATE privs: SELECT,INSERT,UPDATE
@ -213,7 +213,7 @@ EXAMPLES = r'''
grant_option: yes grant_option: yes
- name: Same as above leveraging default values - name: Same as above leveraging default values
postgresql_privs: community.general.postgresql_privs:
db: library db: library
privs: SELECT,INSERT,UPDATE privs: SELECT,INSERT,UPDATE
objs: books,authors objs: books,authors
@ -224,7 +224,7 @@ EXAMPLES = r'''
# Note that role "reader" will be *granted* INSERT privilege itself if this # Note that role "reader" will be *granted* INSERT privilege itself if this
# isn't already the case (since state: present). # isn't already the case (since state: present).
- name: Revoke privs from reader - name: Revoke privs from reader
postgresql_privs: community.general.postgresql_privs:
db: library db: library
state: present state: present
priv: INSERT priv: INSERT
@ -234,7 +234,7 @@ EXAMPLES = r'''
# "public" is the default schema. This also works for PostgreSQL 8.x. # "public" is the default schema. This also works for PostgreSQL 8.x.
- name: REVOKE INSERT, UPDATE ON ALL TABLES IN SCHEMA public FROM reader - name: REVOKE INSERT, UPDATE ON ALL TABLES IN SCHEMA public FROM reader
postgresql_privs: community.general.postgresql_privs:
db: library db: library
state: absent state: absent
privs: INSERT,UPDATE privs: INSERT,UPDATE
@ -242,7 +242,7 @@ EXAMPLES = r'''
role: reader role: reader
- name: GRANT ALL PRIVILEGES ON SCHEMA public, math TO librarian - name: GRANT ALL PRIVILEGES ON SCHEMA public, math TO librarian
postgresql_privs: community.general.postgresql_privs:
db: library db: library
privs: ALL privs: ALL
type: schema type: schema
@ -251,7 +251,7 @@ EXAMPLES = r'''
# Note the separation of arguments with colons. # Note the separation of arguments with colons.
- name: GRANT ALL PRIVILEGES ON FUNCTION math.add(int, int) TO librarian, reader - name: GRANT ALL PRIVILEGES ON FUNCTION math.add(int, int) TO librarian, reader
postgresql_privs: community.general.postgresql_privs:
db: library db: library
privs: ALL privs: ALL
type: function type: function
@ -262,7 +262,7 @@ EXAMPLES = r'''
# Note that group role memberships apply cluster-wide and therefore are not # Note that group role memberships apply cluster-wide and therefore are not
# restricted to database "library" here. # restricted to database "library" here.
- name: GRANT librarian, reader TO alice, bob WITH ADMIN OPTION - name: GRANT librarian, reader TO alice, bob WITH ADMIN OPTION
postgresql_privs: community.general.postgresql_privs:
db: library db: library
type: group type: group
objs: librarian,reader objs: librarian,reader
@ -272,7 +272,7 @@ EXAMPLES = r'''
# Note that here "db: postgres" specifies the database to connect to, not the # Note that here "db: postgres" specifies the database to connect to, not the
# database to grant privileges on (which is specified via the "objs" param) # database to grant privileges on (which is specified via the "objs" param)
- name: GRANT ALL PRIVILEGES ON DATABASE library TO librarian - name: GRANT ALL PRIVILEGES ON DATABASE library TO librarian
postgresql_privs: community.general.postgresql_privs:
db: postgres db: postgres
privs: ALL privs: ALL
type: database type: database
@ -282,7 +282,7 @@ EXAMPLES = r'''
# If objs is omitted for type "database", it defaults to the database # If objs is omitted for type "database", it defaults to the database
# to which the connection is established # to which the connection is established
- name: GRANT ALL PRIVILEGES ON DATABASE library TO librarian - name: GRANT ALL PRIVILEGES ON DATABASE library TO librarian
postgresql_privs: community.general.postgresql_privs:
db: library db: library
privs: ALL privs: ALL
type: database type: database
@ -293,7 +293,7 @@ EXAMPLES = r'''
# ALL_DEFAULT works only with privs=ALL # ALL_DEFAULT works only with privs=ALL
# For specific # For specific
- name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO librarian - name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO librarian
postgresql_privs: community.general.postgresql_privs:
db: library db: library
objs: ALL_DEFAULT objs: ALL_DEFAULT
privs: ALL privs: ALL
@ -306,7 +306,7 @@ EXAMPLES = r'''
# ALL_DEFAULT works only with privs=ALL # ALL_DEFAULT works only with privs=ALL
# For specific # For specific
- name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO reader, step 1 - name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO reader, step 1
postgresql_privs: community.general.postgresql_privs:
db: library db: library
objs: TABLES,SEQUENCES objs: TABLES,SEQUENCES
privs: SELECT privs: SELECT
@ -314,7 +314,7 @@ EXAMPLES = r'''
role: reader role: reader
- name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO reader, step 2 - name: ALTER DEFAULT PRIVILEGES ON DATABASE library TO reader, step 2
postgresql_privs: community.general.postgresql_privs:
db: library db: library
objs: TYPES objs: TYPES
privs: USAGE privs: USAGE
@ -323,7 +323,7 @@ EXAMPLES = r'''
# Available since version 2.8 # Available since version 2.8
- name: GRANT ALL PRIVILEGES ON FOREIGN DATA WRAPPER fdw TO reader - name: GRANT ALL PRIVILEGES ON FOREIGN DATA WRAPPER fdw TO reader
postgresql_privs: community.general.postgresql_privs:
db: test db: test
objs: fdw objs: fdw
privs: ALL privs: ALL
@ -332,7 +332,7 @@ EXAMPLES = r'''
# Available since community.general 0.2.0 # Available since community.general 0.2.0
- name: GRANT ALL PRIVILEGES ON TYPE customtype TO reader - name: GRANT ALL PRIVILEGES ON TYPE customtype TO reader
postgresql_privs: community.general.postgresql_privs:
db: test db: test
objs: customtype objs: customtype
privs: ALL privs: ALL
@ -341,7 +341,7 @@ EXAMPLES = r'''
# Available since version 2.8 # Available since version 2.8
- name: GRANT ALL PRIVILEGES ON FOREIGN SERVER fdw_server TO reader - name: GRANT ALL PRIVILEGES ON FOREIGN SERVER fdw_server TO reader
postgresql_privs: community.general.postgresql_privs:
db: test db: test
objs: fdw_server objs: fdw_server
privs: ALL privs: ALL
@ -351,7 +351,7 @@ EXAMPLES = r'''
# Available since version 2.8 # Available since version 2.8
# Grant 'execute' permissions on all functions in schema 'common' to role 'caller' # Grant 'execute' permissions on all functions in schema 'common' to role 'caller'
- name: GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA common TO caller - name: GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA common TO caller
postgresql_privs: community.general.postgresql_privs:
type: function type: function
state: present state: present
privs: EXECUTE privs: EXECUTE
@ -365,7 +365,7 @@ EXAMPLES = r'''
# default to the role reader. # default to the role reader.
# For specific # For specific
- name: ALTER privs - name: ALTER privs
postgresql_privs: community.general.postgresql_privs:
db: library db: library
schema: library schema: library
objs: TABLES objs: TABLES
@ -380,7 +380,7 @@ EXAMPLES = r'''
# default from the role reader. # default from the role reader.
# For specific # For specific
- name: ALTER privs - name: ALTER privs
postgresql_privs: community.general.postgresql_privs:
db: library db: library
state: absent state: absent
schema: library schema: library
@ -392,7 +392,7 @@ EXAMPLES = r'''
# Available since community.general 0.2.0 # Available since community.general 0.2.0
- name: Grant type privileges for pg_catalog.numeric type to alice - name: Grant type privileges for pg_catalog.numeric type to alice
postgresql_privs: community.general.postgresql_privs:
type: type type: type
roles: alice roles: alice
privs: ALL privs: ALL

View file

@ -95,12 +95,12 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create a new publication with name "acme" targeting all tables in database "test". - name: Create a new publication with name "acme" targeting all tables in database "test".
postgresql_publication: community.general.postgresql_publication:
db: test db: test
name: acme name: acme
- name: Create publication "acme" publishing only prices and vehicles tables. - name: Create publication "acme" publishing only prices and vehicles tables.
postgresql_publication: community.general.postgresql_publication:
name: acme name: acme
tables: tables:
- prices - prices
@ -109,7 +109,7 @@ EXAMPLES = r'''
- name: > - name: >
Create publication "acme", set user alice as an owner, targeting all tables. Create publication "acme", set user alice as an owner, targeting all tables.
Allowable DML operations are INSERT and UPDATE only Allowable DML operations are INSERT and UPDATE only
postgresql_publication: community.general.postgresql_publication:
name: acme name: acme
owner: alice owner: alice
parameters: parameters:
@ -118,7 +118,7 @@ EXAMPLES = r'''
- name: > - name: >
Assuming publication "acme" exists and there are targeted Assuming publication "acme" exists and there are targeted
tables "prices" and "vehicles", add table "stores" to the publication. tables "prices" and "vehicles", add table "stores" to the publication.
postgresql_publication: community.general.postgresql_publication:
name: acme name: acme
tables: tables:
- prices - prices
@ -126,7 +126,7 @@ EXAMPLES = r'''
- stores - stores
- name: Remove publication "acme" if exists in database "test". - name: Remove publication "acme" if exists in database "test".
postgresql_publication: community.general.postgresql_publication:
db: test db: test
name: acme name: acme
state: absent state: absent

View file

@ -88,12 +88,12 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Simple select query to acme db - name: Simple select query to acme db
postgresql_query: community.general.postgresql_query:
db: acme db: acme
query: SELECT version() query: SELECT version()
- name: Select query to db acme with positional arguments and non-default credentials - name: Select query to db acme with positional arguments and non-default credentials
postgresql_query: community.general.postgresql_query:
db: acme db: acme
login_user: django login_user: django
login_password: mysecretpass login_password: mysecretpass
@ -103,7 +103,7 @@ EXAMPLES = r'''
- test - test
- name: Select query to test_db with named_args - name: Select query to test_db with named_args
postgresql_query: community.general.postgresql_query:
db: test_db db: test_db
query: SELECT * FROM test WHERE id = %(id_val)s AND story = %(story_val)s query: SELECT * FROM test WHERE id = %(id_val)s AND story = %(story_val)s
named_args: named_args:
@ -111,12 +111,12 @@ EXAMPLES = r'''
story_val: test story_val: test
- name: Insert query to test_table in db test_db - name: Insert query to test_table in db test_db
postgresql_query: community.general.postgresql_query:
db: test_db db: test_db
query: INSERT INTO test_table (id, story) VALUES (2, 'my_long_story') query: INSERT INTO test_table (id, story) VALUES (2, 'my_long_story')
- name: Run queries from SQL script using UTF-8 client encoding for session - name: Run queries from SQL script using UTF-8 client encoding for session
postgresql_query: community.general.postgresql_query:
db: test_db db: test_db
path_to_script: /var/lib/pgsql/test.sql path_to_script: /var/lib/pgsql/test.sql
positional_args: positional_args:
@ -124,7 +124,7 @@ EXAMPLES = r'''
encoding: UTF-8 encoding: UTF-8
- name: Example of using autocommit parameter - name: Example of using autocommit parameter
postgresql_query: community.general.postgresql_query:
db: test_db db: test_db
query: VACUUM query: VACUUM
autocommit: yes autocommit: yes
@ -132,7 +132,7 @@ EXAMPLES = r'''
- name: > - name: >
Insert data to the column of array type using positional_args. Insert data to the column of array type using positional_args.
Note that we use quotes here, the same as for passing JSON, etc. Note that we use quotes here, the same as for passing JSON, etc.
postgresql_query: community.general.postgresql_query:
query: INSERT INTO test_table (array_column) VALUES (%s) query: INSERT INTO test_table (array_column) VALUES (%s)
positional_args: positional_args:
- '{1,2,3}' - '{1,2,3}'
@ -147,7 +147,7 @@ EXAMPLES = r'''
my_arr: '{1, 2, 3}' my_arr: '{1, 2, 3}'
- name: Select from test table by passing positional_args as arrays - name: Select from test table by passing positional_args as arrays
postgresql_query: community.general.postgresql_query:
query: SELECT * FROM test_array_table WHERE arr_col1 = %s AND arr_col2 = %s query: SELECT * FROM test_array_table WHERE arr_col1 = %s AND arr_col2 = %s
positional_args: positional_args:
- '{{ my_list }}' - '{{ my_list }}'

View file

@ -95,17 +95,17 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create a new schema with name acme in test database - name: Create a new schema with name acme in test database
postgresql_schema: community.general.postgresql_schema:
db: test db: test
name: acme name: acme
- name: Create a new schema acme with a user bob who will own it - name: Create a new schema acme with a user bob who will own it
postgresql_schema: community.general.postgresql_schema:
name: acme name: acme
owner: bob owner: bob
- name: Drop schema "acme" with cascade - name: Drop schema "acme" with cascade
postgresql_schema: community.general.postgresql_schema:
name: acme name: acme
state: absent state: absent
cascade_drop: yes cascade_drop: yes

View file

@ -165,25 +165,25 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create an ascending bigint sequence called foobar in the default - name: Create an ascending bigint sequence called foobar in the default
database database
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
- name: Create an ascending integer sequence called foobar, starting at 101 - name: Create an ascending integer sequence called foobar, starting at 101
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
data_type: integer data_type: integer
start: 101 start: 101
- name: Create an descending sequence called foobar, starting at 101 and - name: Create an descending sequence called foobar, starting at 101 and
preallocated 10 sequence numbers in cache preallocated 10 sequence numbers in cache
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
increment: -1 increment: -1
cache: 10 cache: 10
start: 101 start: 101
- name: Create an ascending sequence called foobar, which cycle between 1 to 10 - name: Create an ascending sequence called foobar, which cycle between 1 to 10
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
cycle: yes cycle: yes
min: 1 min: 1
@ -191,32 +191,32 @@ EXAMPLES = r'''
- name: Create an ascending bigint sequence called foobar in the default - name: Create an ascending bigint sequence called foobar in the default
database with owner foobar database with owner foobar
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
owner: foobar owner: foobar
- name: Rename an existing sequence named foo to bar - name: Rename an existing sequence named foo to bar
postgresql_sequence: community.general.postgresql_sequence:
name: foo name: foo
rename_to: bar rename_to: bar
- name: Change the schema of an existing sequence to foobar - name: Change the schema of an existing sequence to foobar
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
newschema: foobar newschema: foobar
- name: Change the owner of an existing sequence to foobar - name: Change the owner of an existing sequence to foobar
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
owner: foobar owner: foobar
- name: Drop a sequence called foobar - name: Drop a sequence called foobar
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
state: absent state: absent
- name: Drop a sequence called foobar with cascade - name: Drop a sequence called foobar with cascade
postgresql_sequence: community.general.postgresql_sequence:
name: foobar name: foobar
cascade: yes cascade: yes
state: absent state: absent

View file

@ -90,14 +90,14 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Restore wal_keep_segments parameter to initial state - name: Restore wal_keep_segments parameter to initial state
postgresql_set: community.general.postgresql_set:
name: wal_keep_segments name: wal_keep_segments
reset: yes reset: yes
# Set work_mem parameter to 32MB and show what's been changed and restart is required or not # Set work_mem parameter to 32MB and show what's been changed and restart is required or not
# (output example: "msg": "work_mem 4MB >> 64MB restart_req: False") # (output example: "msg": "work_mem 4MB >> 64MB restart_req: False")
- name: Set work mem parameter - name: Set work mem parameter
postgresql_set: community.general.postgresql_set:
name: work_mem name: work_mem
value: 32mb value: 32mb
register: set register: set
@ -110,12 +110,12 @@ EXAMPLES = r'''
# (If you passed the value that was different from the current server setting). # (If you passed the value that was different from the current server setting).
- name: Set log_min_duration_statement parameter to 1 second - name: Set log_min_duration_statement parameter to 1 second
postgresql_set: community.general.postgresql_set:
name: log_min_duration_statement name: log_min_duration_statement
value: 1s value: 1s
- name: Set wal_log_hints parameter to default value (remove parameter from postgresql.auto.conf) - name: Set wal_log_hints parameter to default value (remove parameter from postgresql.auto.conf)
postgresql_set: community.general.postgresql_set:
name: wal_log_hints name: wal_log_hints
value: default value: default
''' '''

View file

@ -101,19 +101,19 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create physical_one physical slot if doesn't exist - name: Create physical_one physical slot if doesn't exist
become_user: postgres become_user: postgres
postgresql_slot: community.general.postgresql_slot:
slot_name: physical_one slot_name: physical_one
db: ansible db: ansible
- name: Remove physical_one slot if exists - name: Remove physical_one slot if exists
become_user: postgres become_user: postgres
postgresql_slot: community.general.postgresql_slot:
slot_name: physical_one slot_name: physical_one
db: ansible db: ansible
state: absent state: absent
- name: Create logical_one logical slot to the database acme if doesn't exist - name: Create logical_one logical slot to the database acme if doesn't exist
postgresql_slot: community.general.postgresql_slot:
name: logical_slot_one name: logical_slot_one
slot_type: logical slot_type: logical
state: present state: present
@ -121,7 +121,7 @@ EXAMPLES = r'''
db: "acme" db: "acme"
- name: Remove logical_one slot if exists from the cluster running on another host and non-standard port - name: Remove logical_one slot if exists from the cluster running on another host and non-standard port
postgresql_slot: community.general.postgresql_slot:
name: logical_one name: logical_one
login_host: mydatabase.example.org login_host: mydatabase.example.org
port: 5433 port: 5433

View file

@ -122,7 +122,7 @@ EXAMPLES = r'''
Create acme subscription in mydb database using acme_publication and Create acme subscription in mydb database using acme_publication and
the following connection parameters to connect to the publisher. the following connection parameters to connect to the publisher.
Set the subscription owner as alice. Set the subscription owner as alice.
postgresql_subscription: community.general.postgresql_subscription:
db: mydb db: mydb
name: acme name: acme
state: present state: present
@ -136,7 +136,7 @@ EXAMPLES = r'''
dbname: mydb dbname: mydb
- name: Assuming that acme subscription exists, try to change conn parameters - name: Assuming that acme subscription exists, try to change conn parameters
postgresql_subscription: community.general.postgresql_subscription:
db: mydb db: mydb
name: acme name: acme
connparams: connparams:
@ -147,20 +147,20 @@ EXAMPLES = r'''
connect_timeout: 100 connect_timeout: 100
- name: Refresh acme publication - name: Refresh acme publication
postgresql_subscription: community.general.postgresql_subscription:
db: mydb db: mydb
name: acme name: acme
state: refresh state: refresh
- name: Drop acme subscription from mydb with dependencies (cascade=yes) - name: Drop acme subscription from mydb with dependencies (cascade=yes)
postgresql_subscription: community.general.postgresql_subscription:
db: mydb db: mydb
name: acme name: acme
state: absent state: absent
cascade: yes cascade: yes
- name: Assuming that acme subscription exists and enabled, disable the subscription - name: Assuming that acme subscription exists and enabled, disable the subscription
postgresql_subscription: community.general.postgresql_subscription:
db: mydb db: mydb
name: acme name: acme
state: present state: present

View file

@ -134,14 +134,14 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create tbl2 in the acme database with the DDL like tbl1 with testuser as an owner - name: Create tbl2 in the acme database with the DDL like tbl1 with testuser as an owner
postgresql_table: community.general.postgresql_table:
db: acme db: acme
name: tbl2 name: tbl2
like: tbl1 like: tbl1
owner: testuser owner: testuser
- name: Create tbl2 in the acme database and tablespace ssd with the DDL like tbl1 including comments and indexes - name: Create tbl2 in the acme database and tablespace ssd with the DDL like tbl1 including comments and indexes
postgresql_table: community.general.postgresql_table:
db: acme db: acme
table: tbl2 table: tbl2
like: tbl1 like: tbl1
@ -149,7 +149,7 @@ EXAMPLES = r'''
tablespace: ssd tablespace: ssd
- name: Create test_table with several columns in ssd tablespace with fillfactor=10 and autovacuum_analyze_threshold=1 - name: Create test_table with several columns in ssd tablespace with fillfactor=10 and autovacuum_analyze_threshold=1
postgresql_table: community.general.postgresql_table:
name: test_table name: test_table
columns: columns:
- id bigserial primary key - id bigserial primary key
@ -161,44 +161,44 @@ EXAMPLES = r'''
- autovacuum_analyze_threshold=1 - autovacuum_analyze_threshold=1
- name: Create an unlogged table in schema acme - name: Create an unlogged table in schema acme
postgresql_table: community.general.postgresql_table:
name: acme.useless_data name: acme.useless_data
columns: waste_id int columns: waste_id int
unlogged: true unlogged: true
- name: Rename table foo to bar - name: Rename table foo to bar
postgresql_table: community.general.postgresql_table:
table: foo table: foo
rename: bar rename: bar
- name: Rename table foo from schema acme to bar - name: Rename table foo from schema acme to bar
postgresql_table: community.general.postgresql_table:
name: acme.foo name: acme.foo
rename: bar rename: bar
- name: Set owner to someuser - name: Set owner to someuser
postgresql_table: community.general.postgresql_table:
name: foo name: foo
owner: someuser owner: someuser
- name: Change tablespace of foo table to new_tablespace and set owner to new_user - name: Change tablespace of foo table to new_tablespace and set owner to new_user
postgresql_table: community.general.postgresql_table:
name: foo name: foo
tablespace: new_tablespace tablespace: new_tablespace
owner: new_user owner: new_user
- name: Truncate table foo - name: Truncate table foo
postgresql_table: community.general.postgresql_table:
name: foo name: foo
truncate: yes truncate: yes
- name: Drop table foo from schema acme - name: Drop table foo from schema acme
postgresql_table: community.general.postgresql_table:
name: acme.foo name: acme.foo
state: absent state: absent
- name: Drop table bar cascade - name: Drop table bar cascade
postgresql_table: community.general.postgresql_table:
name: bar name: bar
state: absent state: absent
cascade: yes cascade: yes

View file

@ -109,31 +109,31 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Create a new tablespace called acme and set bob as an its owner - name: Create a new tablespace called acme and set bob as an its owner
postgresql_tablespace: community.general.postgresql_tablespace:
name: acme name: acme
owner: bob owner: bob
location: /data/foo location: /data/foo
- name: Create a new tablespace called bar with tablespace options - name: Create a new tablespace called bar with tablespace options
postgresql_tablespace: community.general.postgresql_tablespace:
name: bar name: bar
set: set:
random_page_cost: 1 random_page_cost: 1
seq_page_cost: 1 seq_page_cost: 1
- name: Reset random_page_cost option - name: Reset random_page_cost option
postgresql_tablespace: community.general.postgresql_tablespace:
name: bar name: bar
set: set:
random_page_cost: reset random_page_cost: reset
- name: Rename the tablespace from bar to pcie_ssd - name: Rename the tablespace from bar to pcie_ssd
postgresql_tablespace: community.general.postgresql_tablespace:
name: bar name: bar
rename_to: pcie_ssd rename_to: pcie_ssd
- name: Drop tablespace called bloat - name: Drop tablespace called bloat
postgresql_tablespace: community.general.postgresql_tablespace:
name: bloat name: bloat
state: absent state: absent
''' '''

View file

@ -176,7 +176,7 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Connect to acme database, create django user, and grant access to database and products table - name: Connect to acme database, create django user, and grant access to database and products table
postgresql_user: community.general.postgresql_user:
db: acme db: acme
name: django name: django
password: ceec4eif7ya password: ceec4eif7ya
@ -184,7 +184,7 @@ EXAMPLES = r'''
expires: "Jan 31 2020" expires: "Jan 31 2020"
- name: Add a comment on django user - name: Add a comment on django user
postgresql_user: community.general.postgresql_user:
db: acme db: acme
name: django name: django
comment: This is a test user comment: This is a test user
@ -192,13 +192,13 @@ EXAMPLES = r'''
# Connect to default database, create rails user, set its password (MD5-hashed), # Connect to default database, create rails user, set its password (MD5-hashed),
# and grant privilege to create other databases and demote rails from super user status if user exists # and grant privilege to create other databases and demote rails from super user status if user exists
- name: Create rails user, set MD5-hashed password, grant privs - name: Create rails user, set MD5-hashed password, grant privs
postgresql_user: community.general.postgresql_user:
name: rails name: rails
password: md59543f1d82624df2b31672ec0f7050460 password: md59543f1d82624df2b31672ec0f7050460
role_attr_flags: CREATEDB,NOSUPERUSER role_attr_flags: CREATEDB,NOSUPERUSER
- name: Connect to acme database and remove test user privileges from there - name: Connect to acme database and remove test user privileges from there
postgresql_user: community.general.postgresql_user:
db: acme db: acme
name: test name: test
priv: "ALL/products:ALL" priv: "ALL/products:ALL"
@ -206,14 +206,14 @@ EXAMPLES = r'''
fail_on_user: no fail_on_user: no
- name: Connect to test database, remove test user from cluster - name: Connect to test database, remove test user from cluster
postgresql_user: community.general.postgresql_user:
db: test db: test
name: test name: test
priv: ALL priv: ALL
state: absent state: absent
- name: Connect to acme database and set user's password with no expire date - name: Connect to acme database and set user's password with no expire date
postgresql_user: community.general.postgresql_user:
db: acme db: acme
name: django name: django
password: mysupersecretword password: mysupersecretword
@ -224,13 +224,13 @@ EXAMPLES = r'''
# INSERT,UPDATE/table:SELECT/anothertable:ALL # INSERT,UPDATE/table:SELECT/anothertable:ALL
- name: Connect to test database and remove an existing user's password - name: Connect to test database and remove an existing user's password
postgresql_user: community.general.postgresql_user:
db: test db: test
user: test user: test
password: "" password: ""
- name: Create user test and grant group user_ro and user_rw to it - name: Create user test and grant group user_ro and user_rw to it
postgresql_user: community.general.postgresql_user:
name: test name: test
groups: groups:
- user_ro - user_ro
@ -239,7 +239,7 @@ EXAMPLES = r'''
# Create user with a cleartext password if it does not exist or update its password. # Create user with a cleartext password if it does not exist or update its password.
# The password will be encrypted with SCRAM algorithm (available since PostgreSQL 10) # The password will be encrypted with SCRAM algorithm (available since PostgreSQL 10)
- name: Create appclient user with SCRAM-hashed password - name: Create appclient user with SCRAM-hashed password
postgresql_user: community.general.postgresql_user:
name: appclient name: appclient
password: "secret123" password: "secret123"
environment: environment:

View file

@ -68,16 +68,16 @@ extends_documentation_fragment:
EXAMPLES = r''' EXAMPLES = r'''
- name: Collect information about all supported user objects of the acme database - name: Collect information about all supported user objects of the acme database
postgresql_user_obj_stat_info: community.general.postgresql_user_obj_stat_info:
db: acme db: acme
- name: Collect information about all supported user objects in the custom schema of the acme database - name: Collect information about all supported user objects in the custom schema of the acme database
postgresql_user_obj_stat_info: community.general.postgresql_user_obj_stat_info:
db: acme db: acme
schema: custom schema: custom
- name: Collect information about user tables and indexes in the acme database - name: Collect information about user tables and indexes in the acme database
postgresql_user_obj_stat_info: community.general.postgresql_user_obj_stat_info:
db: acme db: acme
filter: tables, indexes filter: tables, indexes
''' '''