Skip to content

backport 337 to stable-1 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions plugins/modules/postgresql_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
- Mark I(src)/I(dst) as a program. Data will be copied to/from a program.
- See block Examples and PROGRAM arg description U(https://www.postgresql.org/docs/current/sql-copy.html).
type: bool
default: no
default: false
options:
description:
- Options of COPY command.
Expand All @@ -71,17 +71,17 @@
type: str
trust_input:
description:
- If C(no), check whether values of parameters are potentially dangerous.
- It makes sense to use C(no) only when SQL injections are possible.
- If C(false), check whether values of parameters are potentially dangerous.
- It makes sense to use C(false) only when SQL injections are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
notes:
- Supports PostgreSQL version 9.4+.
- COPY command is only allowed to database superusers.
- If I(check_mode=yes), we just check the src/dst table availability
- If I(check_mode=true), we just check the src/dst table availability
and return the COPY query that actually has not been executed.
- If i(check_mode=yes) and the source has been passed as SQL, the module
- If i(check_mode=true) and the source has been passed as SQL, the module
will execute it and rolled the transaction back but pay attention
it can affect database performance (e.g., if SQL collects a lot of data).

Expand Down Expand Up @@ -137,7 +137,7 @@
community.postgresql.postgresql_copy:
src: my_table
copy_to: 'gzip > /tmp/data.csv.gz'
program: yes
program: true
options:
format: csv

Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/postgresql_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@
version_added: '0.2.0'
trust_input:
description:
- If C(no), check whether values of parameters I(owner), I(conn_limit), I(encoding),
- If C(false), check whether values of parameters I(owner), I(conn_limit), I(encoding),
I(db), I(template), I(tablespace), I(session_role) are potentially dangerous.
- It makes sense to use C(no) only when SQL injections via the parameters are possible.
- It makes sense to use C(false) only when SQL injections via the parameters are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
seealso:
- name: CREATE DATABASE reference
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/postgresql_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
- Automatically install/remove any extensions that this extension depends on
that are not already installed/removed (supported since PostgreSQL 9.6).
type: bool
default: no
default: false
login_unix_socket:
description:
- Path to a Unix domain socket for local connections.
Expand Down Expand Up @@ -81,11 +81,11 @@
type: str
trust_input:
description:
- If C(no), check whether values of parameters I(ext), I(schema),
- If C(false), check whether values of parameters I(ext), I(schema),
I(version), I(session_role) are potentially dangerous.
- It makes sense to use C(no) only when SQL injections via the parameters are possible.
- It makes sense to use C(false) only when SQL injections via the parameters are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
seealso:
- name: PostgreSQL extensions
Expand Down Expand Up @@ -148,7 +148,7 @@
community.postgresql.postgresql_ext:
name: cube
db: acme
cascade: yes
cascade: true
state: absent

- name: Create extension foo of version 1.2 or update it to that version if it's already created and a valid update path exists
Expand Down
32 changes: 16 additions & 16 deletions plugins/modules/postgresql_idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@
concurrent:
description:
- Enable or disable concurrent mode (CREATE / DROP INDEX CONCURRENTLY).
- Pay attention, if I(concurrent=no), the table will be locked (ACCESS EXCLUSIVE) during the building process.
- Pay attention, if I(concurrent=false), the table will be locked (ACCESS EXCLUSIVE) during the building process.
For more information about the lock levels see U(https://www.postgresql.org/docs/current/explicit-locking.html).
- If the building process was interrupted for any reason when I(cuncurrent=yes), the index becomes invalid.
- If the building process was interrupted for any reason when I(cuncurrent=true), the index becomes invalid.
In this case it should be dropped and created again.
- Mutually exclusive with I(cascade=yes).
- Mutually exclusive with I(cascade=true).
type: bool
default: yes
default: true
unique:
description:
- Enable unique index.
- Only btree currently supports unique indexes.
type: bool
default: no
default: false
version_added: '0.2.0'
tablespace:
description:
Expand All @@ -105,17 +105,17 @@
- Automatically drop objects that depend on the index,
and in turn all objects that depend on those objects.
- It used only with I(state=absent).
- Mutually exclusive with I(concurrent=yes).
- Mutually exclusive with I(concurrent=true).
type: bool
default: no
default: false
trust_input:
description:
- If C(no), check whether values of parameters I(idxname), I(session_role),
- If C(false), check whether values of parameters I(idxname), I(session_role),
I(schema), I(table), I(columns), I(tablespace), I(storage_params),
I(cond) are potentially dangerous.
- It makes sense to use C(no) only when SQL injections via the parameters are possible.
- It makes sense to use C(false) only when SQL injections via the parameters are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'

seealso:
Expand All @@ -137,7 +137,7 @@
notes:
- Supports C(check_mode).
- The index building process can affect database performance.
- To avoid table locks on production databases, use I(concurrent=yes) (default behavior).
- To avoid table locks on production databases, use I(concurrent=true) (default behavior).

author:
- Andrew Klychkov (@Andersson007)
Expand Down Expand Up @@ -182,7 +182,7 @@
idxname: gin0_idx
table: test
columns: comment gin_trgm_ops
concurrent: no
concurrent: false
idxtype: gin

- name: Drop btree test_idx concurrently
Expand All @@ -196,8 +196,8 @@
db: mydb
idxname: test_idx
state: absent
cascade: yes
concurrent: no
cascade: true
concurrent: false

- name: Create btree index test_idx concurrently on columns id,comment where column id > 1
community.postgresql.postgresql_idx:
Expand All @@ -213,8 +213,8 @@
table: products
columns: name
name: test_unique_idx
unique: yes
concurrent: no
unique: true
concurrent: false
'''

RETURN = r'''
Expand Down
14 changes: 7 additions & 7 deletions plugins/modules/postgresql_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
type: str
trust_input:
description:
- If C(no), check whether a 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.
- If C(false), check whether a value of I(session_role) is potentially dangerous.
- It makes sense to use C(false) only when SQL injections via I(session_role) are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
seealso:
- module: community.postgresql.postgresql_ping
Expand All @@ -72,21 +72,21 @@
# ansible databases -m postgresql_info -a 'filter=!settings'

- name: Collect PostgreSQL version and extensions
become: yes
become: true
become_user: postgres
community.postgresql.postgresql_info:
filter: ver*,ext*

- name: Collect all info except settings and roles
become: yes
become: true
become_user: postgres
community.postgresql.postgresql_info:
filter: "!settings,!roles"

# On FreeBSD with PostgreSQL 9.5 version and lower use pgsql user to become
# and pass "postgres" as a database to connect to
- name: Collect tablespaces and repl_slots info
become: yes
become: true
become_user: pgsql
community.postgresql.postgresql_info:
db: postgres
Expand All @@ -95,7 +95,7 @@
- repl_sl*

- name: Collect all info except databases
become: yes
become: true
become_user: postgres
community.postgresql.postgresql_info:
filter:
Expand Down
40 changes: 20 additions & 20 deletions plugins/modules/postgresql_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
relationship with a PostgreSQL database.
- The module can be used on the machine where executed or on a remote host.
- When removing a language from a database, it is possible that dependencies prevent
the database from being removed. In that case, you can specify I(cascade=yes) to
the database from being removed. In that case, you can specify I(cascade=true) to
automatically drop objects that depend on the language (such as functions in the
language).
- In case the language can't be deleted because it is required by the
database system, you can specify I(fail_on_drop=no) to ignore the error.
database system, you can specify I(fail_on_drop=false) to ignore the error.
- Be careful when marking a language as trusted since this could be a potential
security breach. Untrusted languages allow only users with the PostgreSQL superuser
privilege to use this language to create new functions.
Expand All @@ -38,7 +38,7 @@
description:
- Make this language trusted for the selected db.
type: bool
default: 'no'
default: 'false'
db:
description:
- Name of database to connect to and where the language will be added, removed or changed.
Expand All @@ -51,20 +51,20 @@
- Marks the language as trusted, even if it's marked as untrusted in pg_pltemplate.
- Use with care!
type: bool
default: 'no'
default: 'false'
fail_on_drop:
description:
- If C(yes), fail when removing a language. Otherwise just log and continue.
- If C(true), fail when removing a language. Otherwise just log and continue.
- In some cases, it is not possible to remove a language (used by the db-system).
- When dependencies block the removal, consider using I(cascade).
type: bool
default: 'yes'
default: 'true'
cascade:
description:
- When dropping a language, also delete object that depend on this language.
- Only used when I(state=absent).
type: bool
default: 'no'
default: 'false'
session_role:
description:
- Switch to session_role after connecting.
Expand Down Expand Up @@ -104,11 +104,11 @@
version_added: '0.2.0'
trust_input:
description:
- If C(no), check whether values of parameters I(lang), I(session_role),
- If C(false), check whether values of parameters I(lang), I(session_role),
I(owner) are potentially dangerous.
- It makes sense to use C(no) only when SQL injections via the parameters are possible.
- It makes sense to use C(false) only when SQL injections via the parameters are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
seealso:
- name: PostgreSQL languages
Expand Down Expand Up @@ -145,8 +145,8 @@
db: testdb
lang: pltclu
state: present
trust: yes
force_trust: yes
trust: true
force_trust: true

- name: Remove language pltclu from database testdb
community.postgresql.postgresql_lang:
Expand All @@ -159,14 +159,14 @@
db: testdb
lang: pltclu
state: absent
cascade: yes
cascade: true

- name: Remove language c from database testdb but ignore errors if something prevents the removal
community.postgresql.postgresql_lang:
db: testdb
lang: pltclu
state: absent
fail_on_drop: no
fail_on_drop: false

- name: In testdb change owner of mylang to alice
community.postgresql.postgresql_lang:
Expand Down Expand Up @@ -279,13 +279,13 @@ def main():
db=dict(type="str", required=True, aliases=["login_db"]),
lang=dict(type="str", required=True, aliases=["name"]),
state=dict(type="str", default="present", choices=["absent", "present"]),
trust=dict(type="bool", default="no"),
force_trust=dict(type="bool", default="no"),
cascade=dict(type="bool", default="no"),
fail_on_drop=dict(type="bool", default="yes"),
trust=dict(type="bool", default="false"),
force_trust=dict(type="bool", default="false"),
cascade=dict(type="bool", default="false"),
fail_on_drop=dict(type="bool", default="true"),
session_role=dict(type="str"),
owner=dict(type="str"),
trust_input=dict(type="bool", default="yes")
trust_input=dict(type="bool", default="true")
)

module = AnsibleModule(
Expand Down Expand Up @@ -340,7 +340,7 @@ def main():
changed = lang_drop(cursor, lang, cascade)
if fail_on_drop and not changed:
msg = ("unable to drop language, use cascade "
"to delete dependencies or fail_on_drop=no to ignore")
"to delete dependencies or fail_on_drop=false to ignore")
module.fail_json(msg=msg)
kw['lang_dropped'] = changed

Expand Down
16 changes: 8 additions & 8 deletions plugins/modules/postgresql_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
groups:
description:
- The list of groups (roles) that need to be granted to or revoked from I(target_roles).
required: yes
required: true
type: list
elements: str
aliases:
Expand All @@ -33,7 +33,7 @@
target_roles:
description:
- The list of target roles (groups will be granted to them).
required: yes
required: true
type: list
elements: str
aliases:
Expand All @@ -42,8 +42,8 @@
- user
fail_on_role:
description:
- If C(yes), fail when group or target_role doesn't exist. If C(no), just warn and continue.
default: yes
- If C(true), fail when group or target_role doesn't exist. If C(false), just warn and continue.
default: true
type: bool
state:
description:
Expand All @@ -68,11 +68,11 @@
type: str
trust_input:
description:
- If C(no), check whether values of parameters I(groups),
- If C(false), check whether values of parameters I(groups),
I(target_roles), I(session_role) are potentially dangerous.
- It makes sense to use C(no) only when SQL injections via the parameters are possible.
- It makes sense to use C(false) only when SQL injections via the parameters are possible.
type: bool
default: yes
default: true
version_added: '0.2.0'
seealso:
- module: community.postgresql.postgresql_user
Expand Down Expand Up @@ -109,7 +109,7 @@
- read_only
- exec_func
target_role: bob
fail_on_role: no
fail_on_role: false
state: absent
'''

Expand Down
Loading