From ebb534166ee2c7137850aca93d59e00cffb24cfd Mon Sep 17 00:00:00 2001 From: Michael Galati <11300961+leetoburrito@users.noreply.github.com> Date: Mon, 24 Nov 2025 12:32:16 -0800 Subject: [PATCH] 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. --- 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 8ecf032609..c4dd224cd8 100644 --- a/plugins/modules/mas.py +++ b/plugins/modules/mas.py @@ -195,8 +195,14 @@ class Mas: 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]))