From 159f38f4f240030b4016db3697cf577f5e98a275 Mon Sep 17 00:00:00 2001 From: Simon Kelly Date: Tue, 13 Oct 2020 11:36:23 +0200 Subject: [PATCH] postgresql_ext: sort list of available versions (#1078) * sort list of available versions If `version == 'latest'` then the version is set to `available_versions[-1]` however `available_versions` was not previously sorted so the ordering was the natural order of the `pg_available_extension_versions` view. * remove unnecessary lambda * create changelog fragment for #1078 * add PR link to changelog fragment Co-authored-by: Andrew Klychkov Co-authored-by: Andrew Klychkov --- ...tgresql_ext_fix_version_selection_when_version_is_latest.yml | 2 ++ plugins/modules/database/postgresql/postgresql_ext.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1078-postgresql_ext_fix_version_selection_when_version_is_latest.yml diff --git a/changelogs/fragments/1078-postgresql_ext_fix_version_selection_when_version_is_latest.yml b/changelogs/fragments/1078-postgresql_ext_fix_version_selection_when_version_is_latest.yml new file mode 100644 index 00000000000..1c72755dced --- /dev/null +++ b/changelogs/fragments/1078-postgresql_ext_fix_version_selection_when_version_is_latest.yml @@ -0,0 +1,2 @@ +bugfixes: +- postgresql_ext - fix version selection when ``version=latest`` (https://github.com/ansible-collections/community.general/pull/1078). diff --git a/plugins/modules/database/postgresql/postgresql_ext.py b/plugins/modules/database/postgresql/postgresql_ext.py index 867350c923f..6a3dfdae6c0 100644 --- a/plugins/modules/database/postgresql/postgresql_ext.py +++ b/plugins/modules/database/postgresql/postgresql_ext.py @@ -295,7 +295,7 @@ def ext_get_versions(cursor, ext): if current_version == '0': current_version = False - return (current_version, available_versions) + return (current_version, sorted(available_versions, key=LooseVersion)) # =========================================== # Module execution.