Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented May 22, 2023

This is a backport of PR #6534 as merged into main (a9fd9f8).

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

SUMMARY

This code was not treated at all by the module and therefore considered a faillure and the changed status was never set.

After my fix the exitcode 102 will be treated exactly like 0 by the module internally, 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 "register" and a "failed_when" property to pass as OK in this event.

Example:

  tasks:
    - name: Apply patches on OpenSUSE/SUSE Linux
      zypper:
        name: '*'
        state: latest
        type: patch
        extra_args_precommand: '--non-interactive-include-reboot-patches'
      register: zypper_cmd
      failed_when: zypper_cmd.rc not in [0, 102]

    - name: Reboot the SUSE/OpenSUSE box if kernel updated
      reboot:
        msg: "Reboot initiated by Ansible for kernel updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 10
        post_reboot_delay: 30
        test_command: uptime
      when: zypper_cmd.rc == 102

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

zypper

ADDITIONAL INFORMATION

When used to do updates of the type "patch" the zypper module failed in case the updates were successfull, but resulted in the system needing a reboot. In that case the changed status was not correctly set. After my fix the task will still be treated a faillure by ansible unless you treat the rc 102 in a failed_when statement as shown above, but the changed state will be correctly set.

…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 <[email protected]>

* Add URL.

---------

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Alex <[email protected]>
(cherry picked from commit a9fd9f8)
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) labels May 22, 2023
@felixfontein felixfontein merged commit f847531 into stable-6 May 22, 2023
@felixfontein felixfontein deleted the patchback/backports/stable-6/a9fd9f8982a1f2ff7de3939bb885c9a7d8174439/pr-6534 branch May 22, 2023 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants