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

zypper: support transactional-updates (#3164) (#3193)

* zypper: support transactional-updates

- Check if transactional updates are in use by checking for the
  existence of /var/lib/misc/transactional-update.state
- Prefix zypper-commands with /sbin/transactional-update --continue --drop-if-no-change --quiet run
  if this is the case

fixes ansible-collections/community.general#3159

* re-add get_bin_path for executables

* fix typo

(cherry picked from commit 6033ce695b)

Co-authored-by: Sebastian <sebix@sebix.at>
This commit is contained in:
patchback[bot] 2021-08-12 08:29:22 +02:00 committed by GitHub
parent d71c10da27
commit 0eecd48ea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- zypper - prefix zypper commands with ``/sbin/transactional-update --continue --drop-if-no-change --quiet run`` if transactional updates are detected (https://github.com/ansible-collections/community.general/issues/3159).

View file

@ -29,6 +29,7 @@ author:
short_description: Manage packages on SUSE and openSUSE
description:
- Manage packages on SUSE and openSUSE using the zypper and rpm tools.
- Also supports transactional updates, by running zypper inside C(/sbin/transactional-update --continue --drop-if-no-change --quiet run).
options:
name:
description:
@ -213,6 +214,7 @@ EXAMPLES = '''
ZYPP_LOCK_TIMEOUT: 20
'''
import os.path
import xml
import re
from xml.dom.minidom import parseString as parseXML
@ -337,6 +339,8 @@ def get_cmd(m, subcommand):
is_install = subcommand in ['install', 'update', 'patch', 'dist-upgrade']
is_refresh = subcommand == 'refresh'
cmd = [m.get_bin_path('zypper', required=True), '--quiet', '--non-interactive', '--xmlout']
if transactional_updates():
cmd = [m.get_bin_path('transactional-update', required=True), '--continue', '--drop-if-no-change', '--quiet', 'run'] + cmd
if m.params['extra_args_precommand']:
args_list = m.params['extra_args_precommand'].split()
cmd.extend(args_list)
@ -491,6 +495,10 @@ def repo_refresh(m):
return retvals
def transactional_updates():
return os.path.exists('/var/lib/misc/transactional-update.state')
# ===========================================
# Main control flow