Merge pull request #623 from AdmiralNemo/portage-fixes

Portage fixes for check mode
This commit is contained in:
Greg DeKoenigsberg 2015-06-21 23:59:20 -04:00
commit 44eb758dc7

View file

@ -254,6 +254,8 @@ def emerge_packages(module, packages):
break
else:
module.exit_json(changed=False, msg='Packages already present.')
if module.check_mode:
module.exit_json(changed=True, msg='Packages would be installed.')
args = []
emerge_flags = {
@ -298,13 +300,18 @@ def emerge_packages(module, packages):
changed = True
for line in out.splitlines():
if re.match(r'(?:>+) Emerging (?:binary )?\(1 of', line):
msg = 'Packages installed.'
break
elif module.check_mode and re.match(r'\[(binary|ebuild)', line):
msg = 'Packages would be installed.'
break
else:
changed = False
msg = 'No packages installed.'
module.exit_json(
changed=changed, cmd=cmd, rc=rc, stdout=out, stderr=err,
msg='Packages installed.',
msg=msg,
)