mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* pacman: fix returned code when ignorepkg has been defined
* add changelog
* make ignored check preciser
(cherry picked from commit c0740ca398
)
Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
parent
ea873ae471
commit
ce92da7e70
2 changed files with 17 additions and 7 deletions
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- pacman - fix changed status when ignorepkg has been defined (https://github.com/ansible-collections/community.general/issues/1758).
|
|
@ -237,16 +237,23 @@ def upgrade(module, pacman_path):
|
|||
# e.g., "ansible 2.7.1-1 -> 2.7.2-1"
|
||||
regex = re.compile(r'([\w+\-.@]+) (\S+-\S+) -> (\S+-\S+)')
|
||||
for p in data:
|
||||
m = regex.search(p)
|
||||
packages.append(m.group(1))
|
||||
if module._diff:
|
||||
diff['before'] += "%s-%s\n" % (m.group(1), m.group(2))
|
||||
diff['after'] += "%s-%s\n" % (m.group(1), m.group(3))
|
||||
if '[ignored]' not in p:
|
||||
m = regex.search(p)
|
||||
packages.append(m.group(1))
|
||||
if module._diff:
|
||||
diff['before'] += "%s-%s\n" % (m.group(1), m.group(2))
|
||||
diff['after'] += "%s-%s\n" % (m.group(1), m.group(3))
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True, msg="%s package(s) would be upgraded" % (len(data)), packages=packages, diff=diff)
|
||||
if packages:
|
||||
module.exit_json(changed=True, msg="%s package(s) would be upgraded" % (len(data)), packages=packages, diff=diff)
|
||||
else:
|
||||
module.exit_json(changed=False, msg='Nothing to upgrade', packages=packages)
|
||||
rc, stdout, stderr = module.run_command(cmdupgrade, check_rc=False)
|
||||
if rc == 0:
|
||||
module.exit_json(changed=True, msg='System upgraded', packages=packages, diff=diff)
|
||||
if packages:
|
||||
module.exit_json(changed=True, msg='System upgraded', packages=packages, diff=diff)
|
||||
else:
|
||||
module.exit_json(changed=False, msg='Nothing to upgrade', packages=packages)
|
||||
else:
|
||||
module.fail_json(msg="Could not upgrade")
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue