From 39f3b151e84b1ec772eeaa550c28484c8a2f2331 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 27 Oct 2024 21:36:12 +1300 Subject: [PATCH] ansible_galaxy_install: add return value version (#9060) * add return value version * add changelog frag --- .../fragments/9060-ansible-galaxy-install-version.yml | 2 ++ plugins/modules/ansible_galaxy_install.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/9060-ansible-galaxy-install-version.yml diff --git a/changelogs/fragments/9060-ansible-galaxy-install-version.yml b/changelogs/fragments/9060-ansible-galaxy-install-version.yml new file mode 100644 index 0000000000..87d5137ad2 --- /dev/null +++ b/changelogs/fragments/9060-ansible-galaxy-install-version.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible_galaxy_install - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9060). diff --git a/plugins/modules/ansible_galaxy_install.py b/plugins/modules/ansible_galaxy_install.py index 62de70bb63..ea35b3afc0 100644 --- a/plugins/modules/ansible_galaxy_install.py +++ b/plugins/modules/ansible_galaxy_install.py @@ -188,6 +188,12 @@ new_roles: sample: ansistrano.deploy: 3.8.0 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 @@ -252,7 +258,6 @@ class AnsibleGalaxyInstall(ModuleHelper): if not match: self.do_raise("Unable to determine ansible-galaxy version from: {0}".format(line)) version = match.group("version") - version = tuple(int(x) for x in version.split('.')[:3]) return version try: @@ -265,7 +270,8 @@ class AnsibleGalaxyInstall(ModuleHelper): return runner, ctx.run() 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): 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)