From 3ae95a351dd4d64fe509b965c0a1f05650c15308 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Thu, 27 Apr 2023 15:53:49 +1200 Subject: [PATCH] fail rightfully when install with different channel does not work --- plugins/modules/snap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py index b47b20065df..77880a4d73a 100644 --- a/plugins/modules/snap.py +++ b/plugins/modules/snap.py @@ -162,6 +162,7 @@ class Snap(StateModuleHelper): __disable_re = re.compile(r'(?:\S+\s+){5}(?P\S+)') __set_param_re = re.compile(r'(?P\S+:)?(?P\S+)\s*=\s*(?P.+)') __list_re = re.compile(r'^(?P\S+)\s+\S+\s+\S+\s+(?P\S+)') + __install_re = re.compile(r'(?P\S+)\s.+\sinstalled') module = dict( argument_spec={ 'name': dict(type='list', elements='str', required=True), @@ -301,7 +302,10 @@ def process_actionable_snaps(self, actionable_snaps): self.vars.cmd, rc, out, err = self._run_multiple_commands(params, actionable_snaps) if rc == 0: - return + match_install = [self.__install_re.match(line) for line in out.split('\n')] + match_install = [m.group('name') in actionable_snaps for m in match_install if m] + if len(match_install) == len(commands): + return classic_snap_pattern = re.compile(r'^error: This revision of snap "(?P\w+)"' r' was published using classic confinement')