diff --git a/changelogs/fragments/4651-zypper-checkmode-fix.yaml b/changelogs/fragments/4651-zypper-checkmode-fix.yaml new file mode 100644 index 0000000000..403e4eead6 --- /dev/null +++ b/changelogs/fragments/4651-zypper-checkmode-fix.yaml @@ -0,0 +1,2 @@ +bugfixes: + - zypper - fix undefined variable when running in check mode (https://github.com/ansible-collections/community.general/pull/4667). diff --git a/plugins/modules/packaging/os/zypper.py b/plugins/modules/packaging/os/zypper.py index ab49051b17..07d71169ec 100644 --- a/plugins/modules/packaging/os/zypper.py +++ b/plugins/modules/packaging/os/zypper.py @@ -323,6 +323,8 @@ def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None): if packages is None: firstrun = True packages = {} + else: + firstrun = False solvable_list = dom.getElementsByTagName('solvable') for solvable in solvable_list: name = solvable.getAttribute('name')