From a2042c9b93deded494267c30c8cb14dd82dfe12d Mon Sep 17 00:00:00 2001 From: Michael Galati <11300961+leetoburrito@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:46:29 -0800 Subject: [PATCH] [PR #11179/ebb53416 backport][stable-11] mas: Fix parsing on mas 3.0.0+. (#11211) mas: Fix parsing on mas 3.0.0+. (#11179) * mas: Fix parsing on mas 3.0.0+. `mas` changed the formatting of `mas list` with version 3, which breaks the parsing this module uses to determine which apps are installed. In particular, app IDs may now have leading space, which causes us to split the string too early. * Changelog fragment. * Better format examples and changlog fragment. (cherry picked from commit ebb534166ee2c7137850aca93d59e00cffb24cfd) --- changelogs/fragments/11179-mas-list-parsing.yml | 3 +++ plugins/modules/mas.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11179-mas-list-parsing.yml diff --git a/changelogs/fragments/11179-mas-list-parsing.yml b/changelogs/fragments/11179-mas-list-parsing.yml new file mode 100644 index 0000000000..c5ee448792 --- /dev/null +++ b/changelogs/fragments/11179-mas-list-parsing.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - mas - parse CLI output correctly when listing installed apps with mas 3.0.0+ (https://github.com/ansible-collections/community.general/pull/11179). diff --git a/plugins/modules/mas.py b/plugins/modules/mas.py index 3659c97636..1dbf921764 100644 --- a/plugins/modules/mas.py +++ b/plugins/modules/mas.py @@ -201,8 +201,14 @@ class Mas(object): rows = [] apps = [] for r in rows: - # Format: "123456789 App Name" - r = r.split(' ', 1) + # mas 2.3.0 and older: + # 123456789 App Name (version) + # 4567890 App Name Longer (version) + # + # mas 3.0.0 and newer: + # 123456789 App Name (version) + # 4567890 App Name Longer (version) + r = r.strip().split(' ', 1) if len(r) == 2: apps.append(int(r[0]))