From 21f86cbb6eb630dea81058e5723e4d150ee72a87 Mon Sep 17 00:00:00 2001 From: Ammar Lakis Date: Sun, 17 Aug 2025 17:09:12 +0200 Subject: [PATCH] Add installed and updated packages to output --- plugins/modules/aur.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/modules/aur.py b/plugins/modules/aur.py index 049955f..c1772d7 100644 --- a/plugins/modules/aur.py +++ b/plugins/modules/aur.py @@ -97,6 +97,14 @@ msg: description: action that has been taken helper: description: the helper that was actually used +installed: + description: list of packages that were newly installed + returned: always + type: list +updated: + description: list of packages that were upgraded + returned: always + type: list ''' EXAMPLES = ''' @@ -256,10 +264,12 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i else: assert use in use_cmd - changed_iter = False + installed_pkgs = [] + updated_pkgs = [] for package in packages: - if state == 'present' and package_installed(module, package): + was_installed = package_installed(module, package) + if state == 'present' and was_installed: rc = 0 continue if use == 'makepkg': @@ -271,7 +281,14 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i command.append(package) rc, out, err = module.run_command(command, check_rc=True) - changed_iter |= not (out == '' or 'up-to-date -- skipping' in out or 'nothing to do' in out.lower()) + changed_pkg = not (out == '' or 'up-to-date -- skipping' in out or 'nothing to do' in out.lower()) + if changed_pkg: + if was_installed: + updated_pkgs.append(package) + else: + installed_pkgs.append(package) + + changed_iter = bool(installed_pkgs or updated_pkgs) message = 'installed package(s)' if changed_iter else 'package(s) already installed' @@ -280,6 +297,8 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i msg=message if not rc else err, helper=use, rc=rc, + installed=installed_pkgs, + updated=updated_pkgs, )