diff --git a/changelogs/fragments/7046-snap-newline-before-separator.yml b/changelogs/fragments/7046-snap-newline-before-separator.yml new file mode 100644 index 0000000000..a2b6ded381 --- /dev/null +++ b/changelogs/fragments/7046-snap-newline-before-separator.yml @@ -0,0 +1,2 @@ +bugfixes: + - snap - fix crash when multiple snaps are specified and one has ``---`` in its description (https://github.com/ansible-collections/community.general/pull/7046). diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py index f92f42636e..485744d910 100644 --- a/plugins/modules/snap.py +++ b/plugins/modules/snap.py @@ -303,7 +303,10 @@ class Snap(StateModuleHelper): return [name] def process_many(rc, out, err): - outputs = out.split("---") + # This needs to be "\n---" instead of just "---" because otherwise + # if a snap uses "---" in its description then that will incorrectly + # be interpreted as a separator between snaps in the output. + outputs = out.split("\n---") res = [] for sout in outputs: res.extend(process_one(rc, sout, ""))