diff --git a/changelogs/fragments/783-fix-gem-installed-versions.yaml b/changelogs/fragments/783-fix-gem-installed-versions.yaml new file mode 100644 index 0000000000..5ad70f8295 --- /dev/null +++ b/changelogs/fragments/783-fix-gem-installed-versions.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "gem - fix get_installed_versions: correctly parse ``default`` version (https://github.com/ansible-collections/community.general/pull/783)." diff --git a/plugins/modules/packaging/language/gem.py b/plugins/modules/packaging/language/gem.py index f686f74924..3d24039f9b 100644 --- a/plugins/modules/packaging/language/gem.py +++ b/plugins/modules/packaging/language/gem.py @@ -157,7 +157,7 @@ def get_installed_versions(module, remote=False): (rc, out, err) = module.run_command(cmd, environ_update=environ, check_rc=True) installed_versions = [] for line in out.splitlines(): - match = re.match(r"\S+\s+\((.+)\)", line) + match = re.match(r"\S+\s+\((?:default: )?(.+)\)", line) if match: versions = match.group(1) for version in versions.split(', '):