From 88e940a3e1682abd550d92d354f6174502d40439 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 17 Oct 2016 13:22:32 +0200 Subject: [PATCH] zypper: fix for checking result is None (#3143) --- .../modules/extras/packaging/os/zypper.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/zypper.py b/lib/ansible/modules/extras/packaging/os/zypper.py index c956feac1a1..7b385e792ea 100644 --- a/lib/ansible/modules/extras/packaging/os/zypper.py +++ b/lib/ansible/modules/extras/packaging/os/zypper.py @@ -267,15 +267,16 @@ def get_cmd(m, subcommand): def set_diff(m, retvals, result): # TODO: if there is only one package, set before/after to version numbers packages = {'installed': [], 'removed': [], 'upgraded': []} - for p in result: - group = result[p]['group'] - if group == 'to-upgrade': - versions = ' (' + result[p]['oldversion'] + ' => ' + result[p]['version'] + ')' - packages['upgraded'].append(p + versions) - elif group == 'to-install': - packages['installed'].append(p) - elif group == 'to-remove': - packages['removed'].append(p) + if result: + for p in result: + group = result[p]['group'] + if group == 'to-upgrade': + versions = ' (' + result[p]['oldversion'] + ' => ' + result[p]['version'] + ')' + packages['upgraded'].append(p + versions) + elif group == 'to-install': + packages['installed'].append(p) + elif group == 'to-remove': + packages['removed'].append(p) output = '' for state in packages: