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

[PR #6534/a9fd9f89 backport][stable-6] added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6559)

added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6534)

* added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.

* removed trailing whitespaces

* added changelogs fragment

* Fix typo.

Co-authored-by: Alex <alexgubin@gmx.de>

* Add URL.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Alex <alexgubin@gmx.de>
(cherry picked from commit a9fd9f8982)

Co-authored-by: tover99 <101673769+tover99@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2023-05-22 04:54:14 +00:00 committed by GitHub
parent df01cde23d
commit f847531a35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- zypper - added handling of zypper exitcode 102. Changed state is set correctly now and rc 102 is still preserved to be evaluated by the playbook (https://github.com/ansible-collections/community.general/pull/6534).

View file

@ -324,10 +324,11 @@ def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None):
m.fail_json(msg=errmsg, rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
else:
return {}, rc, stdout, stderr
elif rc in [0, 106, 103]:
elif rc in [0, 102, 103, 106]:
# zypper exit codes
# 0: success
# 106: signature verification failed
# 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.
# 103: zypper was upgraded, run same command again
if packages is None:
firstrun = True
@ -587,12 +588,12 @@ def main():
elif state in ['installed', 'present', 'latest']:
packages_changed, retvals = package_present(module, name, state == 'latest')
retvals['changed'] = retvals['rc'] == 0 and bool(packages_changed)
retvals['changed'] = retvals['rc'] in [0, 102] and bool(packages_changed)
if module._diff:
set_diff(module, retvals, packages_changed)
if retvals['rc'] != 0:
if retvals['rc'] not in [0, 102]:
module.fail_json(msg="Zypper run failed.", **retvals)
if not retvals['changed']: