diff --git a/plugins/modules/pacman.py b/plugins/modules/pacman.py index 34af969f5c7..5393899b0cc 100644 --- a/plugins/modules/pacman.py +++ b/plugins/modules/pacman.py @@ -707,7 +707,7 @@ def _build_inventory(self): installed_pkgs = {} dummy, stdout, dummy = self.m.run_command([self.pacman_path, "--query"], check_rc=True) # Format of a line: "pacman 6.0.1-2" - query_re = re.compile(r'^(?P\S+)\s+(?P\S+)\s*$') + query_re = re.compile(r'^\s*(?P\S+)\s+(?P\S+)\s*$') for l in stdout.splitlines(): query_match = query_re.match(l) if not query_match: @@ -723,7 +723,7 @@ def _build_inventory(self): # base-devel file # base-devel findutils # ... - query_groups_re = re.compile(r'^(?P\S+)\s+(?P\S+)\s*$') + query_groups_re = re.compile(r'^\s*(?P\S+)\s+(?P\S+)\s*$') for l in stdout.splitlines(): query_groups_match = query_groups_re.match(l) if not query_groups_match: @@ -750,7 +750,7 @@ def _build_inventory(self): # vim-plugins vim-airline-themes # vim-plugins vim-ale # ... - sync_groups_re = re.compile(r'^(?P\S+)\s+(?P\S+)\s*$') + sync_groups_re = re.compile(r'^\s*(?P\S+)\s+(?P\S+)\s*$') for l in stdout.splitlines(): sync_groups_match = sync_groups_re.match(l) if not sync_groups_match: @@ -766,6 +766,7 @@ def _build_inventory(self): stdout = stdout.splitlines() if stdout and "Avoid running" in stdout[0]: stdout = stdout[1:] + stdout = "\n".join(stdout) # non-zero exit with nothing in stdout -> nothing to upgrade, all good # stderr can have warnings, so not checked here @@ -775,7 +776,7 @@ def _build_inventory(self): # Format of lines: # strace 5.14-1 -> 5.15-1 # systemd 249.7-1 -> 249.7-2 [ignored] - for l in stdout: + for l in stdout.splitlines(): l = l.strip() if not l: continue