Skip to content
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

[PR #400/939c2cd6 backport][stable-1] Fix postgresql_set module if single-value param contains comma in value #403

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- postgresql_set - avoid wrong values for single-value parameters containing commas (https://github.com/ansible-collections/community.postgresql/pull/400).
2 changes: 1 addition & 1 deletion plugins/modules/postgresql_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def param_set(cursor, module, name, value, context):
if str(value).lower() == 'default':
query = "ALTER SYSTEM SET %s = DEFAULT" % name
else:
if isinstance(value, str) and ',' in value:
if isinstance(value, str) and ',' in value and not name.endswith(('_command', '_prefix')):
# Issue https://github.com/ansible-collections/community.postgresql/issues/78
# Change value from 'one, two, three' -> "'one','two','three'"
value = ','.join(["'" + elem.strip() + "'" for elem in value.split(',')])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
log_statement: mod
track_functions: none
shared_preload_libraries: 'pg_stat_statements, pgaudit'
log_line_prefix: 'db=%d,user=%u,app=%a,client=%h '

# Check mode:
- name: Set settings in check mode
Expand Down Expand Up @@ -59,3 +60,13 @@
- assert:
that:
- result.stdout == "shared_preload_libraries = 'pg_stat_statements, pgaudit'"

# Test for single-value params with commas and spaces in value
- name: Test single-value param with commas and spaces in value
<<: *task_parameters
shell: "grep log_line_prefix {{ pg_auto_conf }}"
register: result

- assert:
that:
- result.stdout == "log_line_prefix = 'db=%d,user=%u,app=%a,client=%h '"