Merge pull request #36 from juergenhoetzel/diff

Add diff support in check mode
pull/41/head v0.26
kewl 2020-05-10 08:42:43 -04:00 committed by GitHub
commit dff3cfb450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -108,11 +108,17 @@ def check_packages(module, packages):
Inform the user what would change if the module were run
"""
would_be_changed = []
diff = {
'before': '',
'after': '',
}
for package in packages:
installed = package_installed(module, package)
if not installed:
would_be_changed.append(package)
if module._diff:
diff['after'] += package + "\n"
if would_be_changed:
status = True
@ -126,7 +132,7 @@ def check_packages(module, packages):
message = 'all packages are already installed'
else:
message = 'package is already installed'
module.exit_json(changed=status, msg=message)
module.exit_json(changed=status, msg=message, diff=diff)
def install_with_makepkg(module, package):