1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Set firstrun to avoid use before definition (#4667)

* Set firstrun to avoid use before definition

At the moment if zypper updates itself the parse_zypper_xml function
calls itself with packages not None, but in check_mode zypper still
needs to update itself -> rc = 103 and firstrun is undefined

* Add changelog frament

* Update changelogs/fragments/4651-zypper-checkmode-fix.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Georg Vogt <georg.vogt@tngtech.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Ge0rgi0s 2022-05-16 05:40:46 +00:00 committed by GitHub
parent bb5dfef1cc
commit aeeb09f0da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- zypper - fix undefined variable when running in check mode (https://github.com/ansible-collections/community.general/pull/4667).

View file

@ -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')