ansible_galaxy_install: add return value version (#9060)

* add return value version

* add changelog frag
pull/9067/head
Alexei Znamensky 2024-10-27 21:36:12 +13:00 committed by GitHub
parent ccf7f62325
commit 39f3b151e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -0,0 +1,2 @@
minor_changes:
- ansible_galaxy_install - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9060).

View File

@ -188,6 +188,12 @@ new_roles:
sample: sample:
ansistrano.deploy: 3.8.0 ansistrano.deploy: 3.8.0
baztian.xfce: v0.0.3 baztian.xfce: v0.0.3
version:
description: Version of ansible-core for ansible-galaxy.
type: str
returned: always
sample: 2.17.4
version_added: 10.0.0
""" """
import re import re
@ -252,7 +258,6 @@ class AnsibleGalaxyInstall(ModuleHelper):
if not match: if not match:
self.do_raise("Unable to determine ansible-galaxy version from: {0}".format(line)) self.do_raise("Unable to determine ansible-galaxy version from: {0}".format(line))
version = match.group("version") version = match.group("version")
version = tuple(int(x) for x in version.split('.')[:3])
return version return version
try: try:
@ -265,7 +270,8 @@ class AnsibleGalaxyInstall(ModuleHelper):
return runner, ctx.run() return runner, ctx.run()
def __init_module__(self): def __init_module__(self):
self.runner, self.ansible_version = self._get_ansible_galaxy_version() self.runner, self.vars.version = self._get_ansible_galaxy_version()
self.ansible_version = tuple(int(x) for x in self.vars.version.split('.')[:3])
if self.ansible_version < (2, 11): if self.ansible_version < (2, 11):
self.module.fail_json(msg="Support for Ansible 2.9 and ansible-base 2.10 has been removed.") self.module.fail_json(msg="Support for Ansible 2.9 and ansible-base 2.10 has been removed.")
self.vars.set("new_collections", {}, change=True) self.vars.set("new_collections", {}, change=True)