summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Klychkov <aaklychkov@mail.ru>2020-02-15 16:03:53 +0300
committerMatt Clay <matt@mystile.com>2020-05-05 21:05:25 -0700
commit7cb8594e974666e3bdc8e3ae2ab89c707ba1f7eb (patch)
treee11e6a432f16f2c239372c3e72e36a3723084275
parent70b4ce5efdff05bdfd6cc520260a6af974a3cf61 (diff)
downloadansible-7cb8594e974666e3bdc8e3ae2ab89c707ba1f7eb.tar.gz
Bugfix of 67377: postgresql_set converts value to uppercase if "mb" or "gb" or "tb" is in the value string (#67418)
* Bugfix of 67377: postgresql_set converts value to uppercase if "mb" or "gb" or "tb" is in the value string * fix CI * add changelog (cherry picked from commit 59bcc9f739d40c35ec1f471dbd7f30934bccfd94)
-rw-r--r--changelogs/fragments/67418-postgresql_set_converts_value_to_uppercase.yml2
-rw-r--r--lib/ansible/modules/database/postgresql/postgresql_set.py2
-rw-r--r--test/integration/targets/postgresql/tasks/postgresql_set.yml23
3 files changed, 25 insertions, 2 deletions
diff --git a/changelogs/fragments/67418-postgresql_set_converts_value_to_uppercase.yml b/changelogs/fragments/67418-postgresql_set_converts_value_to_uppercase.yml
new file mode 100644
index 0000000000..b3cd21f858
--- /dev/null
+++ b/changelogs/fragments/67418-postgresql_set_converts_value_to_uppercase.yml
@@ -0,0 +1,2 @@
+bugfixes:
+- postgresql_set - fix converting value to uppercase (https://github.com/ansible/ansible/issues/67377).
diff --git a/lib/ansible/modules/database/postgresql/postgresql_set.py b/lib/ansible/modules/database/postgresql/postgresql_set.py
index 49319585bf..7772fdbb3d 100644
--- a/lib/ansible/modules/database/postgresql/postgresql_set.py
+++ b/lib/ansible/modules/database/postgresql/postgresql_set.py
@@ -300,7 +300,7 @@ def main():
# Allow to pass values like 1mb instead of 1MB, etc:
if value:
for unit in POSSIBLE_SIZE_UNITS:
- if unit in value:
+ if value[:-2].isdigit() and unit in value[-2:]:
value = value.upper()
if value and reset:
diff --git a/test/integration/targets/postgresql/tasks/postgresql_set.yml b/test/integration/targets/postgresql/tasks/postgresql_set.yml
index 04d043bc3f..01e6de1d75 100644
--- a/test/integration/targets/postgresql/tasks/postgresql_set.yml
+++ b/test/integration/targets/postgresql/tasks/postgresql_set.yml
@@ -69,7 +69,7 @@
postgresql_set:
<<: *pg_parameters
name: work_mem
- value: 12MB
+ value: 12mb
register: set_wm
- assert:
@@ -281,3 +281,24 @@
- set_aut.changed == false
- set_aut.restart_required == false
- set_aut.value.value == 'off'
+
+ #################
+ # Bugfix of 67377
+ - name: archive command with mb
+ <<: *task_parameters
+ postgresql_set:
+ <<: *pg_parameters
+ name: archive_command
+ value: 'test ! -f /mnt/postgres/mb/%f && cp %p /mnt/postgres/mb/%f'
+
+ # Check:
+ - name: check value
+ <<: *task_parameters
+ postgresql_query:
+ <<: *pg_parameters
+ query: select reset_val from pg_settings where name = 'archive_command'
+ register: result
+
+ - assert:
+ that:
+ - result.query_result.0.reset_val == "test ! -f /mnt/postgres/mb/%f && cp %p /mnt/postgres/mb/%f"