From df5e1946aae13f3aed728ce214b25c1e395ab82c Mon Sep 17 00:00:00 2001 From: Dagobert Michelsen Date: Sat, 31 Jan 2015 22:12:40 +0100 Subject: [PATCH 1/2] Correctly report "changed: false" when trying to install a package not in the catalog. This fixes #230 --- packaging/os/pkgutil.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packaging/os/pkgutil.py b/packaging/os/pkgutil.py index 78a7db72bf5..fe0e82a5ab7 100644 --- a/packaging/os/pkgutil.py +++ b/packaging/os/pkgutil.py @@ -162,10 +162,15 @@ def main(): (rc, out, err) = package_uninstall(module, name) out = out[:75] - if rc is None: + if rc == 0: + result['changed'] = True + else: result['changed'] = False + + if rc is not None and rc != 0: + result['failed'] = True else: - result['changed'] = True + result['failed'] = False if out: result['stdout'] = out From 57c723fcd9a84b2b72e2a32aa31e7543701cd601 Mon Sep 17 00:00:00 2001 From: Dagobert Michelsen Date: Wed, 18 Feb 2015 10:33:21 +0100 Subject: [PATCH 2/2] Adjust setting to better make logic clearer --- packaging/os/pkgutil.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packaging/os/pkgutil.py b/packaging/os/pkgutil.py index fe0e82a5ab7..0204bbae987 100644 --- a/packaging/os/pkgutil.py +++ b/packaging/os/pkgutil.py @@ -162,15 +162,14 @@ def main(): (rc, out, err) = package_uninstall(module, name) out = out[:75] - if rc == 0: + if rc is None: + # pkgutil was not executed because the package was already present/absent + result['changed'] = False + elif rc == 0 result['changed'] = True - else: + else result['changed'] = False - - if rc is not None and rc != 0: result['failed'] = True - else: - result['failed'] = False if out: result['stdout'] = out